0027-Omxdec-Remove-the-global-variables-in-omxdec-it-make.patch 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From d44bd33ca4fa0975f284279916f8709282bfe020 Mon Sep 17 00:00:00 2001
  2. From: Som Qin <som.qin@starfivetech.com>
  3. Date: Fri, 4 Aug 2023 13:57:24 +0800
  4. Subject: [PATCH 6/8] Omxdec: Remove the global variables in omxdec, it make
  5. issue in mutithread.
  6. Signed-off-by: Som Qin <som.qin@starfivetech.com>
  7. ---
  8. libavcodec/omxdec.c | 25 ++++++++++++-------------
  9. 1 file changed, 12 insertions(+), 13 deletions(-)
  10. diff --git a/libavcodec/omxdec.c b/libavcodec/omxdec.c
  11. index d268454..aa3ddea 100755
  12. --- a/libavcodec/omxdec.c
  13. +++ b/libavcodec/omxdec.c
  14. @@ -48,10 +48,6 @@
  15. #include "internal.h"
  16. #include "profiles.h"
  17. -int evnet_bufferflag;
  18. -int dec_out_height;
  19. -int dec_out_width;
  20. -int dec_pix_fmt;
  21. #ifdef OMX_SKIP64BIT
  22. static OMX_TICKS to_omx_ticks(int64_t value)
  23. @@ -354,6 +350,9 @@ typedef struct OMXCodecContext {
  24. int mutex_cond_inited;
  25. int eos_sent, got_eos, evnet_bufferflag, first_get_outbuffer;
  26. + int dec_out_height;
  27. + int dec_out_width;
  28. + int dec_pix_fmt;
  29. int extradata_sent;
  30. int has_cleanup;
  31. @@ -475,11 +474,11 @@ static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, O
  32. }
  33. if (port_params.eDir == OMX_DirOutput) {
  34. out_port_params = port_params;
  35. - dec_out_width = out_port_params.format.video.nFrameWidth;
  36. - dec_out_height = out_port_params.format.video.nFrameHeight;
  37. - dec_pix_fmt = out_port_params.format.video.eColorFormat;
  38. + s->dec_out_width = out_port_params.format.video.nFrameWidth;
  39. + s->dec_out_height = out_port_params.format.video.nFrameHeight;
  40. + s->dec_pix_fmt = out_port_params.format.video.eColorFormat;
  41. - av_log(s->avctx, AV_LOG_VERBOSE, "w:%d, h:%d, fmt:%d\n", dec_out_width, dec_out_height, dec_pix_fmt);
  42. + av_log(s->avctx, AV_LOG_VERBOSE, "w:%d, h:%d, fmt:%d\n", s->dec_out_width, s->dec_out_height, s->dec_pix_fmt);
  43. if (!s->num_out_buffers) {
  44. s->num_out_buffers = out_port_params.nBufferCountActual;
  45. s->out_buffer_headers = av_mallocz(sizeof(OMX_BUFFERHEADERTYPE*) * s->num_out_buffers);
  46. @@ -511,7 +510,7 @@ static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, O
  47. break;
  48. case OMX_EventBufferFlag:
  49. av_log(s->avctx, AV_LOG_VERBOSE, "OMX decoder competd set event_bufferflag\n");
  50. - evnet_bufferflag = 1;
  51. + s->evnet_bufferflag = 1;
  52. default:
  53. av_log(s->avctx, AV_LOG_VERBOSE, "OMX event %d %"PRIx32" %"PRIx32"\n",
  54. event, (uint32_t) data1, (uint32_t) data2);
  55. @@ -1306,7 +1305,7 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  56. /*eos is sent wait for vpu evnet_bufferflag to get all frames
  57. mjpeg: sent a frame, then wait for a decoder frame
  58. */
  59. - if((s->eos_sent && !evnet_bufferflag) || (avctx->codec_id == AV_CODEC_ID_MJPEG )) {
  60. + if((s->eos_sent && !s->evnet_bufferflag) || (avctx->codec_id == AV_CODEC_ID_MJPEG )) {
  61. continue;
  62. }
  63. break;
  64. @@ -1326,9 +1325,9 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  65. goto end;
  66. }
  67. - avctx->width = dec_out_width;
  68. - avctx->height = dec_out_height;
  69. - avctx->pix_fmt = omx_map_color_format(avctx, dec_pix_fmt);
  70. + avctx->width = s->dec_out_width;
  71. + avctx->height = s->dec_out_height;
  72. + avctx->pix_fmt = omx_map_color_format(avctx, s->dec_pix_fmt);
  73. s->stride = avctx->width;
  74. s->plane_size = avctx->height;
  75. --
  76. 2.25.1