Skip to content

Commit

Permalink
Revert "AMD Media - Fix swscale error when using hwdec for amd_media (#…
Browse files Browse the repository at this point in the history
…1310)"

This reverts commit c515cf9.
  • Loading branch information
arvindcheru authored Mar 28, 2024
1 parent c515cf9 commit 70b14ce
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions amd_openvx_extensions/amd_media/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,16 @@ vx_status CLoomIoMediaDecoder::Initialize()
vxAddLogEntry((vx_reference)node, VX_FAILURE, "ERROR: Failed to create specified HW device.\n");
return VX_FAILURE;
}
decoderFormat = codecContext->pix_fmt;
if (decoderFormat == AV_PIX_FMT_YUVJ420P)
decoderFormat = AV_PIX_FMT_YUV420P; // set non-depracated format, vaapi uses NV12 for YUVJ420P
else if (decoderFormat == AV_PIX_FMT_YUVJ422P)
decoderFormat = AV_PIX_FMT_YUV422P; // set non-depracated format
else if (decoderFormat == AV_PIX_FMT_YUVJ444P)
decoderFormat = AV_PIX_FMT_YUV444P; // set non-depracated format
// vaapi uses NV12 for AV_PIX_FMT_YUV420P: looks like FFMpeg is returning the wrong format which can cause swscale to fail
if (decoderFormat == AV_PIX_FMT_YUV420P)
decoderFormat = AV_PIX_FMT_NV12;
} else
decoderFormat = codecContext->pix_fmt; // correct format will be set after
}

if (codecContext->pix_fmt == AV_PIX_FMT_YUVJ420P)
decoderFormat = AV_PIX_FMT_NV12; // set non-depracated format, vaapi uses NV12 for YUVJ420P
else if (codecContext->pix_fmt == AV_PIX_FMT_YUVJ422P)
decoderFormat = AV_PIX_FMT_YUV422P; // set non-depracated format
else if (codecContext->pix_fmt == AV_PIX_FMT_YUVJ444P)
decoderFormat = AV_PIX_FMT_YUV444P; // set non-depracated format
else
decoderFormat = codecContext->pix_fmt; // correct format will be set after vaapi initialization for hwdec

ERROR_CHECK_STATUS(avcodec_open2(codecContext, decoder, nullptr));
SwsContext * swsContext = NULL;
Expand Down Expand Up @@ -695,7 +693,7 @@ vx_status CLoomIoMediaDecoder::ProcessFrame(vx_image output, vx_array aux_data)
// do sws_scale
int ret = sws_scale(conversionContext[mediaIndex], frame->data, frame->linesize, 0, frame->height, dst_data, dst_linesize);
if (ret < decoderImageHeight) {
fprintf(stderr, "Error in output image scaling using sws_scale <%d>\n", ret);
fprintf(stderr, "Error in output image scaling using sws_scale\n");
return VX_FAILURE;
}
#if DUMP_DECODED_FRAME
Expand Down

0 comments on commit 70b14ce

Please sign in to comment.