This decodes more or less single sample we have. Why inter frame decoding looks bad?
Signed-off-by: Paul B Mahol <one...@gmail.com> --- libavcodec/Makefile | 5 ++ libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec_desc.c | 7 +++ libavcodec/h264dec.c | 103 +++++++++++++++++++++++++++++++++++++++- libavcodec/h264dec.h | 3 ++ libavformat/riff.c | 1 + 7 files changed, 120 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3e16a13004..22f456bda3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -386,6 +386,11 @@ OBJS-$(CONFIG_IDF_DECODER) += bintext.o cga_data.o OBJS-$(CONFIG_IFF_ILBM_DECODER) += iff.o OBJS-$(CONFIG_IMC_DECODER) += imc.o OBJS-$(CONFIG_IMM4_DECODER) += imm4.o +OBJS-$(CONFIG_IMM5_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \ + h264_direct.o h264_loopfilter.o \ + h264_mb.o h264_picture.o \ + h264_refs.o h264_sei.o \ + h264_slice.o h264data.o OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 7dbfcb3dda..29bf718fd4 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -155,6 +155,7 @@ extern AVCodec ff_huffyuv_decoder; extern AVCodec ff_idcin_decoder; extern AVCodec ff_iff_ilbm_decoder; extern AVCodec ff_imm4_decoder; +extern AVCodec ff_imm5_decoder; extern AVCodec ff_indeo2_decoder; extern AVCodec ff_indeo3_decoder; extern AVCodec ff_indeo4_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 705a3ce4f3..356cf28325 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -452,6 +452,7 @@ enum AVCodecID { AV_CODEC_ID_MWSC, AV_CODEC_ID_WCMV, AV_CODEC_ID_RASC, + AV_CODEC_ID_IMM5, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 67a30542d1..e630109db4 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1689,6 +1689,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_IMM5, + .type = AVMEDIA_TYPE_VIDEO, + .name = "imm5", + .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM5"), + .props = AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 7b4c5c76ea..76caec65ba 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -412,7 +412,7 @@ static av_cold int h264_decode_init(AVCodecContext *avctx) } avctx->ticks_per_frame = 2; - if (avctx->extradata_size > 0 && avctx->extradata) { + if (avctx->codec_id != AV_CODEC_ID_IMM5 && avctx->extradata_size > 0 && avctx->extradata) { ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size, &h->ps, &h->is_avc, &h->nal_length_size, avctx->err_recognition, avctx); @@ -958,6 +958,76 @@ static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame, return buf_index; } +static uint8_t imm5_chunk0[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0xB, 0xF, 0x88, +}; + +static uint8_t imm5_chunk1[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0x5, 0x83, 0xE2, +}; + +static uint8_t imm5_chunk2[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0x5, 0x81, 0xE8, 0x80, +}; + +static uint8_t imm5_chunk3[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0xB, 0x4, 0xA2, +}; + +static uint8_t imm5_chunk4[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0x5, 0x81, 0x28, 0x80, +}; + +static uint8_t imm5_chunk5[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x1E, 0xF4, 0x5, 0x80, 0x92, 0x20, +}; + +static uint8_t imm5_chunk6[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0xB, 0xF, 0xC8, +}; + +static uint8_t imm5_chunk7[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0x5, 0x83, 0xF2, +}; + +static uint8_t imm5_chunk8[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0x5, 0x81, 0xEC, 0x80, +}; + +static uint8_t imm5_chunk9[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0xB, 0x4, 0xB2, +}; + +static uint8_t imm5_chunk10[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0x5, 0x81, 0x2C, 0x80, +}; + +static uint8_t imm5_chunk11[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x0, 0x1E, 0x9A, 0x74, 0x5, 0x80, 0x93, 0x20, +}; + +static uint8_t imm5_chunkX[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x68, 0xDE, 0x3C, 0x80, +}; + +static uint8_t imm5_chunkY[] = +{ + 0x00, 0x00, 0x00, 0x01, 0x68, 0xCE, 0x32, 0x28, +}; + static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { @@ -968,6 +1038,21 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, int buf_index; int ret; + if (avctx->codec_id == AV_CODEC_ID_IMM5) { + if (avpkt->size > 24) { + int offset; + + av_fast_padded_malloc(&h->imm5_buffer, &h->imm5_buffer_size, buf_size); + memcpy(h->imm5_buffer, imm5_chunk0, sizeof(imm5_chunk0)); + offset = sizeof(imm5_chunk0); + memcpy(h->imm5_buffer + offset, imm5_chunkX, sizeof(imm5_chunkX)); + offset += sizeof(imm5_chunkX); + memcpy(h->imm5_buffer + offset, avpkt->data + 24, buf_size - 24); + buf = h->imm5_buffer; + buf_size = buf_size - 24 + offset; + } + } + h->flags = avctx->flags; h->setup_finished = 0; h->nb_slice_ctx_queued = 0; @@ -1090,3 +1175,19 @@ AVCodec ff_h264_decoder = { .profiles = NULL_IF_CONFIG_SMALL(ff_h264_profiles), .priv_class = &h264_class, }; + +AVCodec ff_imm5_decoder = { + .name = "imm5", + .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM5"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_IMM5, + .priv_data_size = sizeof(H264Context), + .init = h264_decode_init, + .close = h264_decode_end, + .decode = h264_decode_frame, + .capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_DELAY, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_EXPORTS_CROPPING, + .flush = flush_dpb, + .profiles = NULL_IF_CONFIG_SMALL(ff_h264_profiles), +}; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 1d9723260d..1e72781b3f 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -353,6 +353,9 @@ typedef struct H264Context { H2645Packet pkt; + uint8_t *imm5_buffer; + int imm5_buffer_size; + int pixel_shift; ///< 0 for 8-bit H.264, 1 for high-bit-depth H.264 /* coded dimensions -- 16 * mb w/h */ diff --git a/libavformat/riff.c b/libavformat/riff.c index 3907e1a9f3..583c0158d8 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -475,6 +475,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { AV_CODEC_ID_MWSC, MKTAG('M', 'W', 'S', 'C') }, { AV_CODEC_ID_WCMV, MKTAG('W', 'C', 'M', 'V') }, { AV_CODEC_ID_RASC, MKTAG('R', 'A', 'S', 'C') }, + { AV_CODEC_ID_IMM5, MKTAG('I', 'M', 'M', '5') }, { AV_CODEC_ID_NONE, 0 } }; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel