0011-ffmpeg-add-delay-for-decoding.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From f7401faa595d8cd70392c73ce9578ed1e83ed81b Mon Sep 17 00:00:00 2001
  2. From: "arvin.zhu" <arvin.zhu@starfivetech.com>
  3. Date: Thu, 22 Sep 2022 19:06:50 +0800
  4. Subject: [PATCH] ffmpeg: add delay for decoding
  5. add delay for decoding
  6. Signed-off-by: arvin.zhu <arvin.zhu@starfivetech.com>
  7. ---
  8. libavcodec/omxdec.c | 9 ++++++++-
  9. 1 file changed, 8 insertions(+), 1 deletion(-)
  10. mode change 100644 => 100755 libavcodec/omxdec.c
  11. diff --git a/libavcodec/omxdec.c b/libavcodec/omxdec.c
  12. old mode 100644
  13. new mode 100755
  14. index 32f39f3..03a2bca
  15. --- a/libavcodec/omxdec.c
  16. +++ b/libavcodec/omxdec.c
  17. @@ -262,7 +262,7 @@ typedef struct OMXCodecContext {
  18. int mutex_cond_inited;
  19. - int eos_sent, got_eos, evnet_bufferflag;
  20. + int eos_sent, got_eos, evnet_bufferflag, first_get_outbuffer;
  21. int extradata_sent;
  22. @@ -792,6 +792,9 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  23. if (pkt->size) {
  24. + //VPU init and fill buffer slow, so empty buf sleep to send before get vpu fill buf.
  25. + if(!s->first_get_outbuffer)
  26. + av_usleep(100000);
  27. buffer = get_buffer(&s->input_mutex, &s->input_cond,
  28. &s->num_free_in_buffers, s->free_in_buffers, 1);
  29. @@ -831,6 +834,8 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  30. }
  31. } else if (!s->eos_sent) {
  32. + if(!s->first_get_outbuffer)
  33. + av_usleep(1000000);
  34. buffer = get_buffer(&s->input_mutex, &s->input_cond,
  35. &s->num_free_in_buffers, s->free_in_buffers, 1);
  36. @@ -871,6 +876,8 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  37. }
  38. //if (!buffer)
  39. // break;
  40. + if(!s->first_get_outbuffer)
  41. + s->first_get_outbuffer = 1;
  42. if(!buffer->nFilledLen){
  43. av_log(avctx, AV_LOG_ERROR, "buffer->nFilledLen %d\n",(int)buffer->nFilledLen);
  44. --
  45. 2.17.1