#include "decode.h"
#include "h264_parse.h"
#include "hevc_parse.h"
-#include "hwaccel.h"
+#include "hwconfig.h"
#include "internal.h"
#include "mediacodec_wrapper.h"
#include "mediacodecdec_common.h"
AVPacket buffered_pkt;
int delay_flush;
+ int amlogic_mpeg2_api23_workaround;
} MediaCodecH264DecContext;
static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
{
int ret;
+ int sdk_int;
const char *codec_mime = NULL;
goto done;
}
- av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
+ av_log(avctx, AV_LOG_INFO,
+ "MediaCodec started successfully: codec = %s, ret = %d\n",
+ s->ctx->codec_name, ret);
+
+ sdk_int = ff_Build_SDK_INT(avctx);
+ if (sdk_int <= 23 &&
+ strcmp(s->ctx->codec_name, "OMX.amlogic.mpeg2.decoder.awesome") == 0) {
+ av_log(avctx, AV_LOG_INFO, "Enabling workaround for %s on API=%d\n",
+ s->ctx->codec_name, sdk_int);
+ s->amlogic_mpeg2_api23_workaround = 1;
+ }
done:
if (format) {
if (ret >= 0) {
s->buffered_pkt.size -= ret;
s->buffered_pkt.data += ret;
- if (s->buffered_pkt.size <= 0)
+ if (s->buffered_pkt.size <= 0) {
av_packet_unref(&s->buffered_pkt);
+ } else {
+ av_log(avctx, AV_LOG_WARNING,
+ "could not send entire packet in single input buffer (%d < %d)\n",
+ ret, s->buffered_pkt.size+ret);
+ }
} else if (ret < 0 && ret != AVERROR(EAGAIN)) {
return ret;
}
- /* poll for space again */
- continue;
+ if (s->amlogic_mpeg2_api23_workaround && s->buffered_pkt.size <= 0) {
+ /* fallthrough to fetch next packet regardless of input buffer space */
+ } else {
+ /* poll for space again */
+ continue;
+ }
}
/* fetch new packet or eof */
ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, true);
if (ret < 0)
return ret;
+ return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true);
} else if (ret == AVERROR(EAGAIN) && s->ctx->current_input_buffer < 0) {
return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true);
} else if (ret < 0) {