Browse code

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: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/05/17 04:52:35
Showing 2 changed files
... ...
@@ -2979,6 +2979,7 @@ static int opt_qscale(const char *opt, const char *arg)
2979 2979
 static int opt_top_field_first(const char *opt, const char *arg)
2980 2980
 {
2981 2981
     top_field_first = parse_number_or_die(opt, arg, OPT_INT, 0, 1);
2982
+    opt_default(opt, arg);
2982 2983
     return 0;
2983 2984
 }
2984 2985
 
... ...
@@ -29,15 +29,24 @@
29 29
 #include "raw.h"
30 30
 #include "libavutil/intreadwrite.h"
31 31
 #include "libavutil/imgutils.h"
32
+#include "libavutil/opt.h"
32 33
 
33 34
 typedef struct RawVideoContext {
35
+    AVClass *av_class;
34 36
     uint32_t palette[AVPALETTE_COUNT];
35 37
     unsigned char * buffer;  /* block of memory for holding one frame */
36 38
     int             length;  /* number of bytes in buffer */
37 39
     int flip;
38 40
     AVFrame pic;             ///< AVCodecContext.coded_frame
41
+    int tff;
39 42
 } RawVideoContext;
40 43
 
44
+static const AVOption options[]={
45
+{"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},
46
+{NULL}
47
+};
48
+static const AVClass class = { "rawdec", NULL, options, LIBAVUTIL_VERSION_INT };
49
+
41 50
 static const PixelFormatTag pix_fmt_bps_avi[] = {
42 51
     { PIX_FMT_MONOWHITE, 1 },
43 52
     { PIX_FMT_PAL8,    2 },
... ...
@@ -130,6 +139,11 @@ static int raw_decode(AVCodecContext *avctx,
130 130
     frame->pkt_pts          = avctx->pkt->pts;
131 131
     frame->pkt_pos          = avctx->pkt->pos;
132 132
 
133
+    if(context->tff>=0){
134
+        frame->interlaced_frame = 1;
135
+        frame->top_field_first  = context->tff;
136
+    }
137
+
133 138
     //2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
134 139
     if (context->buffer) {
135 140
         int i;
... ...
@@ -214,4 +228,5 @@ AVCodec ff_rawvideo_decoder = {
214 214
     raw_close_decoder,
215 215
     raw_decode,
216 216
     .long_name = NULL_IF_CONFIG_SMALL("raw video"),
217
+    .priv_class= &class,
217 218
 };