[FFmpeg-devel] [PATCH 1/2] MxPEG decoder
Stefano Sabatini
stefano.sabatini-lala
Wed Dec 1 00:17:43 CET 2010
On date Monday 2010-11-01 15:42:11 +0300, Anatoly Nenashev encoded:
[...]
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 385ae02..7fb41a6 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -259,6 +259,7 @@ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4data.o h263dec.o \
> OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
> OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
> OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
> +OBJS-$(CONFIG_MXPEG_DECODER) += mjpegdec.o mjpeg.o
> OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o nellymoser.o
> OBJS-$(CONFIG_NELLYMOSER_ENCODER) += nellymoserenc.o nellymoser.o
> OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 89614ab..6104b53 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -150,6 +150,7 @@ void avcodec_register_all(void)
> REGISTER_DECODER (MSRLE, msrle);
> REGISTER_DECODER (MSVIDEO1, msvideo1);
> REGISTER_DECODER (MSZH, mszh);
> + REGISTER_DECODER (MXPEG, mxpeg);
> REGISTER_DECODER (NUV, nuv);
> REGISTER_ENCDEC (PAM, pam);
> REGISTER_ENCDEC (PBM, pbm);
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 705259e..59d2a3a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -249,6 +249,7 @@ enum CodecID {
> CODEC_ID_A64_MULTI,
> CODEC_ID_A64_MULTI5,
> CODEC_ID_R10K,
> + CODEC_ID_MXPEG,
>
> /* various PCM "codecs" */
> CODEC_ID_PCM_S16LE= 0x10000,
> @@ -652,6 +653,7 @@ typedef struct RcOverride{
> #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations.
> #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined.
> #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes.
> +#define CODEC_FLAG2_COLLECT_FRAME 0x00400000 ///< Decoder must collect full video frame from the parts in incoming packets.
>
> /* Unsupported options :
> * Syntax Arithmetic coding (SAC)
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index e57f74f..f57aa3f 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -112,6 +112,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
> if (avctx->codec->id == CODEC_ID_AMV)
> s->flipped = 1;
>
> + if (avctx->codec_id == CODEC_ID_MXPEG)
> + memset(&s->mxctx, 0, sizeof(s->mxctx));
> +
> return 0;
> }
>
> @@ -205,6 +208,37 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
> return 0;
> }
>
> +static int mjpeg_allocate_picture(MJpegDecodeContext *s)
> +{
> + if(s->picture.data[0])
> + s->avctx->release_buffer(s->avctx, &s->picture);
NitNit: if_( here and below
> +
> + s->picture.reference= 0;
> + if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
> + av_log(s->avctx, AV_LOG_ERROR, "mjpeg get_buffer() failed\n");
"mpjeg" is redundant and is already specified by the context.
> + return -1;
Please return meaningful values, here and below.
[...]
> @@ -1565,3 +1709,18 @@ AVCodec thp_decoder = {
> .max_lowres = 3,
> .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
> };
> +
> +AVCodec mxpeg_decoder = {
> + "mxpeg",
> + AVMEDIA_TYPE_VIDEO,
> + CODEC_ID_MXPEG,
> + sizeof(MJpegDecodeContext),
> + ff_mjpeg_decode_init,
> + NULL,
> + ff_mjpeg_decode_end,
> + ff_mjpeg_decode_frame,
> + CODEC_CAP_DR1,
> + NULL,
> + .max_lowres = 3,
> + .long_name = NULL_IF_CONFIG_SMALL("Mobotix MxPEG video"),
Designated init (.foo = bar) are preferred.
--
FFmpeg = Fast and Fierce Mortal Problematic Excellent Gadget
More information about the ffmpeg-devel
mailing list