int fast = 1;
avctx->workaround_bugs = 1;
- avctx->lowres = 0;
- if(avctx->lowres > codec->max_lowres){
- ALOGW("The maximum value for lowres supported by the decoder is %d",
- codec->max_lowres);
- avctx->lowres= codec->max_lowres;
- }
avctx->idct_algo = 0;
avctx->skip_frame = AVDISCARD_DEFAULT;
avctx->skip_idct = AVDISCARD_DEFAULT;
avctx->error_concealment = 3;
avctx->thread_count = 0;
- if(avctx->lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
- if (fast) avctx->flags2 |= CODEC_FLAG2_FAST;
- if(codec->capabilities & CODEC_CAP_DR1)
+ if (fast) avctx->flags2 |= AV_CODEC_FLAG2_FAST;
+#ifdef CODEC_FLAG_EMU_EDGE
+ if (codec->capabilities & AV_CODEC_CAP_DR1)
avctx->flags |= CODEC_FLAG_EMU_EDGE;
+#endif
}
status_t SoftFFmpegVideo::initDecoder(enum AVCodecID codecID) {
}
if (mCodecAlreadyOpened) {
avcodec_close(mCtx);
+ mCodecAlreadyOpened = false;
}
av_free(mCtx);
mCtx = NULL;
int orig_extradata_size = mCtx->extradata_size;
mCtx->extradata_size += inHeader->nFilledLen;
mCtx->extradata = (uint8_t *)realloc(mCtx->extradata,
- mCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ mCtx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!mCtx->extradata) {
ALOGE("ffmpeg video decoder failed to alloc extradata memory.");
return ERR_OOM;
inHeader->pBuffer + inHeader->nOffset,
inHeader->nFilledLen);
memset(mCtx->extradata + mCtx->extradata_size, 0,
- FF_INPUT_BUFFER_PADDING_SIZE);
+ AV_INPUT_BUFFER_PADDING_SIZE);
}
}
}
if (mEOSStatus == INPUT_EOS_SEEN && (!inHeader || inHeader->nFilledLen == 0)
- && !(mCtx->codec->capabilities & CODEC_CAP_DELAY)) {
+ && !(mCtx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
return ERR_FLUSHED;
}
if (!gotPic) {
ALOGI("ffmpeg video decoder failed to get frame.");
//stop sending empty packets if the decoder is finished
- if (mEOSStatus != INPUT_DATA_AVAILABLE && mCtx->codec->capabilities & CODEC_CAP_DELAY &&
- !inHeader || inHeader->nFilledLen == 0) {
+ if ((mEOSStatus != INPUT_DATA_AVAILABLE && (mCtx->codec->capabilities & AV_CODEC_CAP_DELAY) &&
+ !inHeader) || inHeader->nFilledLen == 0) {
ret = ERR_FLUSHED;
} else {
ret = ERR_NO_FRM;
BufferInfo *outInfo = *outQueue.begin();
OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
- AVPicture pict;
+ uint8_t *data[4];
+ int linesize[4];
+
int64_t pts = AV_NOPTS_VALUE;
uint8_t *dst = outHeader->pBuffer;
uint32_t width = outputBufferWidth();
uint32_t height = outputBufferHeight();
- memset(&pict, 0, sizeof(AVPicture));
- pict.data[0] = dst;
- pict.data[1] = dst + width * height;
- pict.data[2] = pict.data[1] + (width / 2 * height / 2);
- pict.linesize[0] = width;
- pict.linesize[1] = width / 2;
- pict.linesize[2] = width / 2;
+ data[0] = dst;
+ data[1] = dst + width * height;
+ data[2] = data[1] + (width / 2 * height / 2);
+ linesize[0] = width;
+ linesize[1] = width / 2;
+ linesize[2] = width / 2;
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);
return ERR_SWS_FAILED;
}
sws_scale(mImgConvertCtx, mFrame->data, mFrame->linesize,
- 0, height, pict.data, pict.linesize);
+ 0, height, data, linesize);
outHeader->nOffset = 0;
outHeader->nFilledLen = (outputBufferWidth() * outputBufferHeight() * 3) / 2;
}
//process timestamps
+#ifndef LIBAV_CONFIG_H
if (decoder_reorder_pts == -1) {
pts = av_frame_get_best_effort_timestamp(mFrame);
- } else if (decoder_reorder_pts) {
+ } else
+#endif
+ if (decoder_reorder_pts) {
pts = mFrame->pkt_pts;
} else {
pts = mFrame->pkt_dts;
void SoftFFmpegVideo::onReset() {
ALOGV("onReset()");
+ enum AVCodecID codecID = mCtx->codec_id;
+ deInitDecoder();
+ initDecoder(codecID);
SoftVideoDecoderOMXComponent::onReset();
mSignalledError = false;
mExtradataReady = false;