0020-FFmpeg-omxdec-modify-the-range-of-width-and-height-o.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From e29c31f71f4a2cf28142d2440c715a43672b08e8 Mon Sep 17 00:00:00 2001
  2. From: "arvin.zhu" <arvin.zhu@starfivetech.com>
  3. Date: Wed, 16 Nov 2022 11:19:47 +0800
  4. Subject: [PATCH] FFmpeg:omxdec: modify the range of width and height of scale
  5. modify the range of width and height of scale for omx decoder
  6. Signed-off-by: arvin.zhu <arvin.zhu@starfivetech.com>
  7. ---
  8. libavcodec/omxdec.c | 16 ++++++++++++----
  9. 1 file changed, 12 insertions(+), 4 deletions(-)
  10. diff --git a/libavcodec/omxdec.c b/libavcodec/omxdec.c
  11. index 019db2e..4974833 100755
  12. --- a/libavcodec/omxdec.c
  13. +++ b/libavcodec/omxdec.c
  14. @@ -361,7 +361,7 @@ static OMX_ERRORTYPE event_handler(OMX_HANDLETYPE component, OMX_PTR app_data, O
  15. }
  16. break;
  17. case OMX_EventPortSettingsChanged:
  18. - av_log(s->avctx, AV_LOG_ERROR, "OMX port %"PRIu32" settings changed\n", (uint32_t) data1);
  19. + av_log(s->avctx, AV_LOG_VERBOSE, "OMX port %"PRIu32" settings changed\n", (uint32_t) data1);
  20. INIT_STRUCT(video_port_params);
  21. err = OMX_GetParameter(s->handle, OMX_IndexParamVideoInit, &video_port_params);
  22. if(err != OMX_ErrorNone){
  23. @@ -742,15 +742,23 @@ static av_cold int omx_component_init(AVCodecContext *avctx, const char *role)
  24. if (avctx->codec->id == AV_CODEC_ID_H264 || avctx->codec->id == AV_CODEC_ID_HEVC) {
  25. /* Set Scale config setting*/
  26. if ((s->scale_width != 0) && ((s->scale_width < avctx->width/8) ||
  27. - (s->scale_width > avctx->width) || (s->scale_width % 8 != 0))) {
  28. + (s->scale_width > avctx->width) || (s->scale_width % 2 != 0))) {
  29. av_log(avctx, AV_LOG_ERROR, "scale_width: Invalid scale parameter\n");
  30. return AVERROR_INVALIDDATA;
  31. }
  32. + if (s->scale_width == avctx->width/8 && (s->scale_width % 8 != 0)) {
  33. + av_log(avctx, AV_LOG_ERROR, "When scale_width is width/8, scale_width must be a multiple of 8(ceil 8).\n");
  34. + return AVERROR_INVALIDDATA;
  35. + }
  36. if ((s->scale_height != 0) && ((s->scale_height < avctx->height/8) ||
  37. - (s->scale_height > avctx->height) || (s->scale_height % 8 != 0))) {
  38. + (s->scale_height > avctx->height) || (s->scale_height % 2 != 0))) {
  39. av_log(avctx, AV_LOG_ERROR, "scale_height: Invalid scale parameter\n");
  40. return AVERROR_INVALIDDATA;
  41. }
  42. + if (s->scale_height == avctx->height/8 && (s->scale_height % 8 != 0)) {
  43. + av_log(avctx, AV_LOG_ERROR, "When scale_height is height/8, scale_height must be a multiple of 8(ceil 8).\n");
  44. + return AVERROR_INVALIDDATA;
  45. + }
  46. out_port_params.format.video.nFrameWidth = s->scale_width ? s->scale_width : avctx->width;
  47. out_port_params.format.video.nFrameHeight = s->scale_height ? s->scale_height : avctx->height;
  48. @@ -1072,7 +1080,7 @@ static int omx_decode_frame(AVCodecContext *avctx, void *data,
  49. // s->first_get_outbuffer = 1;
  50. if(!buffer->nFilledLen){
  51. - av_log(avctx, AV_LOG_ERROR, "buffer->nFilledLen %d\n",(int)buffer->nFilledLen);
  52. + av_log(avctx, AV_LOG_VERBOSE, "buffer->nFilledLen %d\n",(int)buffer->nFilledLen);
  53. goto end;
  54. }
  55. --
  56. 2.17.1