Browse code

ffmpeg: make 'bits_per_raw_sample' option more useful

Currently bits_per_raw_sample is exposed as an AVCodecContext option.
The option is not very useful, because ffmpeg 1) overwrites it with
a value from the upstream codec, or 2) it resets the value whenever
the video is resampled.

This patch adds the -bits_per_raw sample option to FFmpeg, and
caches the value like is done for the -pix_fmt option.

Example usage:
ffmpeg v210.avi -pix_fmt rgb48 -bits_per_raw_sample 10 out%d.dpx

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Peter Ross authored on 2011/04/03 09:14:00
Showing 1 changed files
... ...
@@ -151,6 +151,7 @@ static int frame_height = 0;
151 151
 static float frame_aspect_ratio = 0;
152 152
 static int frame_aspect_ratio_override = 0;
153 153
 static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
154
+static int frame_bits_per_raw_sample = 0;
154 155
 static enum AVSampleFormat audio_sample_fmt = AV_SAMPLE_FMT_NONE;
155 156
 static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
156 157
 static AVRational frame_rate;
... ...
@@ -2288,7 +2289,7 @@ static int transcode(AVFormatContext **output_files,
2288 2288
                     ost->original_height = icodec->height;
2289 2289
                     ost->original_width  = icodec->width;
2290 2290
 #endif
2291
-                    codec->bits_per_raw_sample= 0;
2291
+                    codec->bits_per_raw_sample= frame_bits_per_raw_sample;
2292 2292
                 }
2293 2293
                 ost->resample_height = icodec->height;
2294 2294
                 ost->resample_width  = icodec->width;
... ...
@@ -3516,6 +3517,7 @@ static void new_video_stream(AVFormatContext *oc, int file_idx)
3516 3516
         video_enc->height = frame_height;
3517 3517
         video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255);
3518 3518
         video_enc->pix_fmt = frame_pix_fmt;
3519
+        video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
3519 3520
         st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
3520 3521
 
3521 3522
         choose_pixel_fmt(st, codec);
... ...
@@ -4315,6 +4317,7 @@ static const OptionDef options[] = {
4315 4315
     { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
4316 4316
     { "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
4317 4317
     { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format, 'list' as argument shows all the pixel formats supported", "format" },
4318
+    { "bits_per_raw_sample", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&frame_bits_per_raw_sample}, "set the number of bits per raw sample", "number" },
4318 4319
     { "croptop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4319 4320
     { "cropbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },
4320 4321
     { "cropleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, use the crop filter instead", "size" },