diff options
Diffstat (limited to 'libavcodec/rawdec.c')
-rw-r--r-- | libavcodec/rawdec.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 6b3387f636..6bf749f4c3 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -2,20 +2,20 @@ * Raw Video Decoder * Copyright (c) 2001 Fabrice Bellard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,16 +29,27 @@ #include "raw.h" #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" +#include "libavutil/opt.h" typedef struct RawVideoContext { + AVClass *av_class; uint32_t palette[AVPALETTE_COUNT]; unsigned char * buffer; /* block of memory for holding one frame */ int length; /* number of bytes in buffer */ int flip; AVFrame pic; ///< AVCodecContext.coded_frame + int tff; } RawVideoContext; +static const AVOption options[]={ +{"top", "top field first", offsetof(RawVideoContext, tff), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM}, +{NULL} +}; +static const AVClass class = { "rawdec", NULL, options, LIBAVUTIL_VERSION_INT }; + static const PixelFormatTag pix_fmt_bps_avi[] = { + { PIX_FMT_MONOWHITE, 1 }, + { PIX_FMT_PAL8, 2 }, { PIX_FMT_PAL8, 4 }, { PIX_FMT_PAL8, 8 }, { PIX_FMT_RGB444, 12 }, @@ -59,10 +70,11 @@ static const PixelFormatTag pix_fmt_bps_mov[] = { { PIX_FMT_RGB555BE, 16 }, { PIX_FMT_RGB24, 24 }, { PIX_FMT_ARGB, 32 }, + { PIX_FMT_MONOWHITE,33 }, { PIX_FMT_NONE, 0 }, }; -static enum PixelFormat find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc) +enum PixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc) { while (tags->pix_fmt >= 0) { if (tags->fourcc == fourcc) @@ -77,11 +89,11 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) RawVideoContext *context = avctx->priv_data; if (avctx->codec_tag == MKTAG('r','a','w',' ')) - avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); + avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); else if (avctx->codec_tag) - avctx->pix_fmt = find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); + avctx->pix_fmt = ff_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); else if (avctx->pix_fmt == PIX_FMT_NONE && avctx->bits_per_coded_sample) - avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); + avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); ff_set_systematic_pal2(context->palette, avctx->pix_fmt); context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); @@ -120,10 +132,17 @@ static int raw_decode(AVCodecContext *avctx, AVFrame * frame = (AVFrame *) data; AVPicture * picture = (AVPicture *) data; + frame->pict_type = avctx->coded_frame->pict_type; frame->interlaced_frame = avctx->coded_frame->interlaced_frame; frame->top_field_first = avctx->coded_frame->top_field_first; frame->reordered_opaque = avctx->reordered_opaque; frame->pkt_pts = avctx->pkt->pts; + frame->pkt_pos = avctx->pkt->pos; + + if(context->tff>=0){ + frame->interlaced_frame = 1; + frame->top_field_first = context->tff; + } //2bpp and 4bpp raw in avi and mov (yes this is ugly ...) if (context->buffer) { @@ -209,4 +228,5 @@ AVCodec ff_rawvideo_decoder = { raw_close_decoder, raw_decode, .long_name = NULL_IF_CONFIG_SMALL("raw video"), + .priv_class= &class, }; |