Commit 9763420b authored by Michael Niedermayer's avatar Michael Niedermayer

rawdec: Allow overriding top field first.

Iam not sure this is the best way to implement it, but its the simplest
and keeps the code seperate from the application. Keeping ffmpeg.c
simple and not requireing user apps to duplicate this code.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 19878374
...@@ -2979,6 +2979,7 @@ static int opt_qscale(const char *opt, const char *arg) ...@@ -2979,6 +2979,7 @@ static int opt_qscale(const char *opt, const char *arg)
static int opt_top_field_first(const char *opt, const char *arg) static int opt_top_field_first(const char *opt, const char *arg)
{ {
top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1); top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1);
opt_default(opt, arg);
return 0; return 0;
} }
......
...@@ -29,15 +29,24 @@ ...@@ -29,15 +29,24 @@
#include "raw.h" #include "raw.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/opt.h"
typedef struct RawVideoContext { typedef struct RawVideoContext {
AVClass *av_class;
uint32_t palette[AVPALETTE_COUNT]; uint32_t palette[AVPALETTE_COUNT];
unsigned char * buffer; /* block of memory for holding one frame */ unsigned char * buffer; /* block of memory for holding one frame */
int length; /* number of bytes in buffer */ int length; /* number of bytes in buffer */
int flip; int flip;
AVFrame pic; ///< AVCodecContext.coded_frame AVFrame pic; ///< AVCodecContext.coded_frame
int tff;
} RawVideoContext; } 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[] = { static const PixelFormatTag pix_fmt_bps_avi[] = {
{ PIX_FMT_MONOWHITE, 1 }, { PIX_FMT_MONOWHITE, 1 },
{ PIX_FMT_PAL8, 2 }, { PIX_FMT_PAL8, 2 },
...@@ -130,6 +139,11 @@ static int raw_decode(AVCodecContext *avctx, ...@@ -130,6 +139,11 @@ static int raw_decode(AVCodecContext *avctx,
frame->pkt_pts = avctx->pkt->pts; frame->pkt_pts = avctx->pkt->pts;
frame->pkt_pos = avctx->pkt->pos; 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 ...) //2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
if (context->buffer) { if (context->buffer) {
int i; int i;
...@@ -214,4 +228,5 @@ AVCodec ff_rawvideo_decoder = { ...@@ -214,4 +228,5 @@ AVCodec ff_rawvideo_decoder = {
raw_close_decoder, raw_close_decoder,
raw_decode, raw_decode,
.long_name = NULL_IF_CONFIG_SMALL("raw video"), .long_name = NULL_IF_CONFIG_SMALL("raw video"),
.priv_class= &class,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment