FFMPEG Plugin: Fix correct decoding of first video frame.

- The first decoded video frame was always zero bytes large, due to passing the
  wrong linesize to the color conversion function. The field containing the
  right linesize (fHeader.u.raw_video.bytes_per_row) simply wasn't initialized
  yet. Fix it by updating fHeader first before applying deinterlacing and color
  converting to the decoded video frame.
  Tested with mpeg2_decoder_test where the first picture now isn't empty
  (black) anymore.
This commit is contained in:
Colin Günther
2014-08-25 14:33:37 +02:00
parent f7f6702203
commit 1c5f18308c
@@ -1364,8 +1364,8 @@ AVCodecDecoder::_CopyChunkToChunkBufferAndAddPadding(const void* chunk,
void void
AVCodecDecoder::_HandleNewVideoFrameAndUpdateSystemState() AVCodecDecoder::_HandleNewVideoFrameAndUpdateSystemState()
{ {
_DeinterlaceAndColorConvertVideoFrame();
_UpdateMediaHeaderForVideoFrame(); _UpdateMediaHeaderForVideoFrame();
_DeinterlaceAndColorConvertVideoFrame();
ConvertAVCodecContextToVideoFrameRate(*fContext, fOutputFrameRate); ConvertAVCodecContextToVideoFrameRate(*fContext, fOutputFrameRate);
@@ -1444,7 +1444,9 @@ AVCodecDecoder::_UpdateMediaHeaderForVideoFrame()
fHeader.file_pos = 0; fHeader.file_pos = 0;
fHeader.orig_size = 0; fHeader.orig_size = 0;
fHeader.start_time = fRawDecodedPicture->pkt_dts; fHeader.start_time = fRawDecodedPicture->pkt_dts;
fHeader.size_used = fDecodedDataSizeInBytes; fHeader.size_used = avpicture_get_size(
colorspace_to_pixfmt(fOutputColorSpace), fRawDecodedPicture->width,
fRawDecodedPicture->height);
fHeader.u.raw_video.display_line_width = fRawDecodedPicture->width; fHeader.u.raw_video.display_line_width = fRawDecodedPicture->width;
fHeader.u.raw_video.display_line_count = fRawDecodedPicture->height; fHeader.u.raw_video.display_line_count = fRawDecodedPicture->height;
fHeader.u.raw_video.bytes_per_row fHeader.u.raw_video.bytes_per_row
@@ -1475,8 +1477,12 @@ AVCodecDecoder::_UpdateMediaHeaderForVideoFrame()
It is assumed that fRawDecodedPicture wasn't deinterlaced and color It is assumed that fRawDecodedPicture wasn't deinterlaced and color
converted yet (otherwise this function behaves in unknown manners). converted yet (otherwise this function behaves in unknown manners).
This function MUST be called after _UpdateMediaHeaderForVideoFrame() as it
relys on the fHeader.size_used and fHeader.u.raw_video.bytes_per_row fields
for correct operation
You should only call this function when you got a new picture decoded by You should only call this function when you got a new picture decoded by
the video decoder.. the video decoder.
When this function finishes the postprocessed video frame will be available When this function finishes the postprocessed video frame will be available
in fPostProcessedDecodedPicture and fDecodedData (fDecodedDataSizeInBytes in fPostProcessedDecodedPicture and fDecodedData (fDecodedDataSizeInBytes
@@ -1526,8 +1532,7 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame()
} }
#endif #endif
fDecodedDataSizeInBytes = avpicture_get_size( fDecodedDataSizeInBytes = fHeader.size_used;
colorspace_to_pixfmt(fOutputColorSpace), displayWidth, displayHeight);
if (fDecodedData == NULL) if (fDecodedData == NULL)
fDecodedData fDecodedData