Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-stagefright-plugins: Commit

external/stagefright-plugins


Commit MetaInfo

Revisionda46d3e6fa26bc9d046d37317236a38f60fb1959 (tree)
Time2017-10-10 02:48:13
AuthorMichael Goffioul <michael.goffioul@gmai...>
CommiterChih-Wei Huang

Log Message

SoftFFmpegVideo: fix adpative video scaling problem

The way I understand it is that the codec is not supposed to scale the
video frames to the buffer size. In case of adpative playback, the frames
may be smaller than the buffer, which corresponds to the max possible
frame size in the adaptive stream.

The patch also drops fiddling with the cropping attributes. I'm not sure
what was the purpose, but I couldn't find equivalent in other sw codecs
like avcdec or mpeg2dec, so I just dropped that and mimiced what the
other sw codecs are doing.

Change Summary

Incremental Difference

--- a/omx/SoftFFmpegVideo.cpp
+++ b/omx/SoftFFmpegVideo.cpp
@@ -589,21 +589,24 @@ int32_t SoftFFmpegVideo::drainOneOutputBuffer() {
589589 int64_t pts = AV_NOPTS_VALUE;
590590 uint8_t *dst = outHeader->pBuffer;
591591
592- uint32_t width = outputBufferWidth();
593- uint32_t height = outputBufferHeight();
592+ uint32_t bufferWidth = outputBufferWidth();
593+ uint32_t bufferHeight = outputBufferHeight();
594+ uint32_t frameWidth = mFrame->width;
595+ uint32_t frameHeight = mFrame->height;
594596
595597 data[0] = dst;
596- data[1] = dst + width * height;
597- data[2] = data[1] + (width / 2 * height / 2);
598- linesize[0] = width;
599- linesize[1] = width / 2;
600- linesize[2] = width / 2;
598+ data[1] = dst + bufferWidth * bufferHeight;
599+ data[2] = data[1] + (bufferWidth / 2 * bufferHeight / 2);
600+ linesize[0] = bufferWidth;
601+ linesize[1] = bufferWidth / 2;
602+ linesize[2] = bufferWidth / 2;
601603
602- ALOGV("drainOneOutputBuffer: frame_width=%d frame_height=%d width=%d height=%d ctx_width=%d ctx_height=%d", mFrame->width, mFrame->height, width, height, mCtx->width, mCtx->height);
604+ ALOGD("drainOneOutputBuffer: frame_width=%d frame_height=%d buffer_width=%d buffer_height=%d ctx_width=%d ctx_height=%d mIsAdaptive=%d",
605+ frameWidth, frameHeight, bufferWidth, bufferHeight, mCtx->width, mCtx->height, mIsAdaptive);
603606
604607 int sws_flags = SWS_BICUBIC;
605608 mImgConvertCtx = sws_getCachedContext(mImgConvertCtx,
606- mFrame->width, mFrame->height, (AVPixelFormat)mFrame->format, width, height,
609+ mFrame->width, mFrame->height, (AVPixelFormat)mFrame->format, mFrame->width, mFrame->height,
607610 AV_PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
608611 if (mImgConvertCtx == NULL) {
609612 ALOGE("Cannot initialize the conversion context");
@@ -613,7 +616,7 @@ int32_t SoftFFmpegVideo::drainOneOutputBuffer() {
613616 0, mFrame->height, data, linesize);
614617
615618 outHeader->nOffset = 0;
616- outHeader->nFilledLen = (outputBufferWidth() * outputBufferHeight() * 3) / 2;
619+ outHeader->nFilledLen = (bufferWidth * bufferHeight * 3) / 2;
617620 outHeader->nFlags = 0;
618621 if (mFrame->key_frame) {
619622 outHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
@@ -697,6 +700,7 @@ void SoftFFmpegVideo::drainAllOutputBuffers() {
697700 }
698701
699702 bool SoftFFmpegVideo::handlePortSettingsChange() {
703+#if 0
700704 CropSettingsMode crop = kCropUnSet;
701705 uint32_t width = outputBufferWidth();
702706 uint32_t height = outputBufferHeight();
@@ -715,6 +719,12 @@ bool SoftFFmpegVideo::handlePortSettingsChange() {
715719 SoftVideoDecoderOMXComponent::handlePortSettingsChange(
716720 &portWillReset, mCtx->width, mCtx->height, crop);
717721 return portWillReset;
722+#else
723+ bool portWillReset = false;
724+ SoftVideoDecoderOMXComponent::handlePortSettingsChange(
725+ &portWillReset, mCtx->width, mCtx->height);
726+ return portWillReset;
727+#endif
718728 }
719729
720730 void SoftFFmpegVideo::onQueueFilled(OMX_U32 portIndex __unused) {
Show on old repository browser