Advertisement
Guest User

Untitled

a guest
Dec 12th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. ilclient_set_fill_buffer_done_callback(decoder->client, fill_buffer_done, decoder);
  2.  
  3. static void fill_buffer_done(void* data, COMPONENT_T* comp) {
  4. H264_decoder *decoder = (H264_decoder *)data;
  5. if (decoder->outbuf) {
  6. //printf("buf size %d addr %p\n",decoder->outbuf->nFilledLen,decoder->outbuf->pBuffer);
  7. }
  8. /* Signal complete event. */
  9. pthread_mutex_lock(&fill_buffer_done_mutex);
  10. fill_buffer_done_val = 1;
  11. pthread_cond_signal(&fill_buffer_done_cond);
  12. pthread_mutex_unlock(&fill_buffer_done_mutex);
  13. }
  14. static int rpi_h264_end_frame(AVCodecContext *avctx) {
  15. struct timeval start,end,start2,end2;
  16. OMXContext *hwctx = avctx->hwaccel_context; // made in vd_ffmpeg.c
  17. H264Context *h = avctx->priv_data;
  18. Picture *pic = h->cur_pic_ptr;
  19. OMX_ERRORTYPE err;
  20. char name[100];
  21. struct rpi_picture_context *pic_ctx = pic->hwaccel_picture_private; // allocated by lib, based on priv_data_size
  22.  
  23. gettimeofday(&start,NULL);
  24.  
  25. if (decoder->outbuf != NULL) {
  26. gettimeofday(&start2,NULL);
  27. err = OMX_FillThisBuffer(decoder->image_resize->handle, decoder->outbuf);
  28. if (err != OMX_ErrorNone) {
  29. printf("error filling buffer: %x\n",err);
  30. } else {
  31. /* Wait for fill_buffer_done. */
  32. pthread_mutex_lock(&fill_buffer_done_mutex);
  33. while (fill_buffer_done_val == 0) {
  34. pthread_cond_wait(&fill_buffer_done_cond, &fill_buffer_done_mutex);
  35. }
  36. fill_buffer_done_val = 0;
  37. pthread_mutex_unlock(&fill_buffer_done_mutex);
  38. }
  39. gettimeofday(&end2,NULL);
  40. } else {
  41. //puts("no outbuf found");
  42. }
  43. if (hwctx != NULL) {
  44. // call the vo module in mplayer
  45. hwctx->render(avctx, &pic->f, pic_ctx->first);
  46. } else {
  47. if (decoder->outbuf != NULL) {
  48. frames++;
  49. #if 0
  50. snprintf(name,100,"/media/videos/4tb/rpi/frame%d.yuv",frames);
  51. FILE *frameout = fopen(name,"w");
  52. fwrite(decoder->outbuf->pBuffer,decoder->outbuf->nFilledLen,1,frameout);
  53. fclose(frameout);
  54. #endif
  55. // start over, with examples from Daemon404
  56. int p;
  57. for (p=0; p < 3; p++) {
  58. uint8_t *buf = pic->f.data[p];
  59. uint8_t *src;
  60. int stride = decoder->stride >> !!p; // 10 17:44:25 * Daemon404 runs in shame
  61. int height = decoder->sliceHeight >> !!p;
  62. if (p==0) src = decoder->outbuf->pBuffer;
  63. else if (p==1) src = decoder->outbuf->pBuffer + (decoder->stride*decoder->sliceHeight);
  64. else if (p==2) src = decoder->outbuf->pBuffer + (decoder->stride*decoder->sliceHeight) + (stride*height);
  65. if (stride != pic->f.linesize[p]) {
  66. printf("stride mismatch between gpu and ffmpeg, %d %d\n",stride,pic->f.linesize[p]);
  67. exit(-2);
  68. }
  69. //printf("buf:%p src:%p stride:%d plane:%d linesize:%d height:%d\n",buf,src,stride,p,pic->f.linesize[p],height);
  70. memcpy(buf,src,stride * height);
  71. }
  72. gettimeofday(&end,NULL);
  73. float total = end.tv_sec - start.tv_sec;
  74. total += (float)(end.tv_usec - start.tv_usec) / 1000000.0;
  75. float total2 = end2.tv_sec - start2.tv_sec;
  76. total2 += (float)(end2.tv_usec - start2.tv_usec) / 1000000.0;
  77. printf("%f %f %3d size:%d offset:%d\n",total,total2,frames,decoder->outbuf->nFilledLen,decoder->outbuf->nOffset);
  78. }
  79. }
  80. //if (frames > 200) exit(-2);
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement