Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ilclient_set_fill_buffer_done_callback(decoder->client, fill_buffer_done, decoder);
- static void fill_buffer_done(void* data, COMPONENT_T* comp) {
- H264_decoder *decoder = (H264_decoder *)data;
- if (decoder->outbuf) {
- //printf("buf size %d addr %p\n",decoder->outbuf->nFilledLen,decoder->outbuf->pBuffer);
- }
- /* Signal complete event. */
- pthread_mutex_lock(&fill_buffer_done_mutex);
- fill_buffer_done_val = 1;
- pthread_cond_signal(&fill_buffer_done_cond);
- pthread_mutex_unlock(&fill_buffer_done_mutex);
- }
- static int rpi_h264_end_frame(AVCodecContext *avctx) {
- struct timeval start,end,start2,end2;
- OMXContext *hwctx = avctx->hwaccel_context; // made in vd_ffmpeg.c
- H264Context *h = avctx->priv_data;
- Picture *pic = h->cur_pic_ptr;
- OMX_ERRORTYPE err;
- char name[100];
- struct rpi_picture_context *pic_ctx = pic->hwaccel_picture_private; // allocated by lib, based on priv_data_size
- gettimeofday(&start,NULL);
- if (decoder->outbuf != NULL) {
- gettimeofday(&start2,NULL);
- err = OMX_FillThisBuffer(decoder->image_resize->handle, decoder->outbuf);
- if (err != OMX_ErrorNone) {
- printf("error filling buffer: %x\n",err);
- } else {
- /* Wait for fill_buffer_done. */
- pthread_mutex_lock(&fill_buffer_done_mutex);
- while (fill_buffer_done_val == 0) {
- pthread_cond_wait(&fill_buffer_done_cond, &fill_buffer_done_mutex);
- }
- fill_buffer_done_val = 0;
- pthread_mutex_unlock(&fill_buffer_done_mutex);
- }
- gettimeofday(&end2,NULL);
- } else {
- //puts("no outbuf found");
- }
- if (hwctx != NULL) {
- // call the vo module in mplayer
- hwctx->render(avctx, &pic->f, pic_ctx->first);
- } else {
- if (decoder->outbuf != NULL) {
- frames++;
- #if 0
- snprintf(name,100,"/media/videos/4tb/rpi/frame%d.yuv",frames);
- FILE *frameout = fopen(name,"w");
- fwrite(decoder->outbuf->pBuffer,decoder->outbuf->nFilledLen,1,frameout);
- fclose(frameout);
- #endif
- // start over, with examples from Daemon404
- int p;
- for (p=0; p < 3; p++) {
- uint8_t *buf = pic->f.data[p];
- uint8_t *src;
- int stride = decoder->stride >> !!p; // 10 17:44:25 * Daemon404 runs in shame
- int height = decoder->sliceHeight >> !!p;
- if (p==0) src = decoder->outbuf->pBuffer;
- else if (p==1) src = decoder->outbuf->pBuffer + (decoder->stride*decoder->sliceHeight);
- else if (p==2) src = decoder->outbuf->pBuffer + (decoder->stride*decoder->sliceHeight) + (stride*height);
- if (stride != pic->f.linesize[p]) {
- printf("stride mismatch between gpu and ffmpeg, %d %d\n",stride,pic->f.linesize[p]);
- exit(-2);
- }
- //printf("buf:%p src:%p stride:%d plane:%d linesize:%d height:%d\n",buf,src,stride,p,pic->f.linesize[p],height);
- memcpy(buf,src,stride * height);
- }
- gettimeofday(&end,NULL);
- float total = end.tv_sec - start.tv_sec;
- total += (float)(end.tv_usec - start.tv_usec) / 1000000.0;
- float total2 = end2.tv_sec - start2.tv_sec;
- total2 += (float)(end2.tv_usec - start2.tv_usec) / 1000000.0;
- printf("%f %f %3d size:%d offset:%d\n",total,total2,frames,decoder->outbuf->nFilledLen,decoder->outbuf->nOffset);
- }
- }
- //if (frames > 200) exit(-2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement