Commit 0ed7bc49 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (31 commits)
  libx264: set default thread count to 0 (auto)
  lavc: cosmetics, group deprecated codec flags
  mpeg12: add 'scan_offset' private option.
  h263/p encoder: add 'structured_slices' private option.
  h263/p encoder: add 'obmc' private option.
  h263p encoder: add 'aiv' private option.
  h263p encoder: add 'umv' private option.
  mpeg12enc/mpeg4videoenc: add 'alternate_scan' private option.
  mjpegdec: add 'extern_huff' private option.
  mpeg4enc: add 'data_partitioning' private option.
  snow: add 'memc_only' private option.
  libx264: add 'mbtree' private option.
  libx264: add 'psy' private option.
  libmp3lame: add 'reservoir' private option.
  mpeg2enc: add 'non_linear_quant' private option
  mpeg12enc: add drop_frame_timecode private option.
  mpeg12enc: add intra_vlc private option.
  VC1: Support dynamic dimension changes
  mjpeg: treat external huffman table setup failure as codec init failure if external huffman table use requested
  lavc: deprecate CODEC_FLAG2_BRDO
  ...

Conflicts:
	avconv.c
	libavcodec/libmp3lame.c
	libavcodec/libx264.c
	libavcodec/mjpegdec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegvideo.h
	libavcodec/vc1.c
	libavcodec/vc1dec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents a9c69362 5d06f152
......@@ -205,7 +205,6 @@ static int exit_on_error = 0;
static int using_stdin = 0;
static int verbose = 1;
static int run_as_daemon = 0;
static int thread_count= 1;
static int q_pressed = 0;
static int64_t video_size = 0;
static int64_t audio_size = 0;
......@@ -2666,16 +2665,6 @@ static int opt_top_field_first(const char *opt, const char *arg)
return opt_default(opt, arg);
}
static int opt_thread_count(const char *opt, const char *arg)
{
thread_count= parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
#if !HAVE_THREADS
if (verbose >= 0)
fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
#endif
return 0;
}
static int opt_audio_sample_fmt(const char *opt, const char *arg)
{
if (strcmp(arg, "list")) {
......@@ -2969,8 +2958,6 @@ static void add_input_streams(AVFormatContext *ic)
InputStream *ist;
char *scale = NULL;
dec->thread_count = thread_count;
input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1);
ist = &input_streams[nb_input_streams - 1];
ist->st = st;
......@@ -3264,8 +3251,6 @@ static OutputStream *new_video_stream(AVFormatContext *oc)
ost->bitstream_filters = video_bitstream_filters;
video_bitstream_filters= NULL;
st->codec->thread_count= thread_count;
video_enc = st->codec;
if(video_codec_tag)
......@@ -3370,8 +3355,6 @@ static OutputStream *new_audio_stream(AVFormatContext *oc)
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
st->codec->thread_count= thread_count;
audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
......@@ -4191,7 +4174,6 @@ static const OptionDef options[] = {
{ "re", OPT_BOOL | OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate", "" },
{ "v", HAS_ARG, {(void*)opt_verbose}, "set the verbosity level", "number" },
{ "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
{ "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
{ "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
{ "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" },
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" },
......
......@@ -574,7 +574,6 @@ typedef struct RcOverride{
#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
#define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
/**
* The parent program guarantees that the input for B-frames containing
* streams is not written to for at least s->max_b_frames+1 frames, if
......@@ -583,7 +582,6 @@ typedef struct RcOverride{
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
......@@ -592,25 +590,42 @@ typedef struct RcOverride{
#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
/* Fx : Flag for h263+ extra options */
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
#define CODEC_FLAG_CLOSED_GOP 0x80000000
#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
/**
* @defgroup deprecated_flags Deprecated codec flags
* Use corresponding private codec options instead.
* @{
*/
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#endif
#if FF_API_MJPEG_GLOBAL_OPTS
#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
#endif
#if FF_API_X264_GLOBAL_OPTS
#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references.
#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames
#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
......@@ -618,17 +633,20 @@ typedef struct RcOverride{
#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization
#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
#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.
#endif
#if FF_API_SNOW_GLOBAL_OPTS
#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
#endif
#if FF_API_LAME_GLOBAL_OPTS
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
#endif
/**
* @}
*/
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
......@@ -2326,8 +2344,7 @@ typedef struct AVCodecContext {
int lowres;
/**
* Bitstream width / height, may be different from width/height if lowres
* or other things are used.
* Bitstream width / height, may be different from width/height if lowres enabled.
* - encoding: unused
* - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
*/
......
......@@ -25,12 +25,15 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "mpegaudio.h"
#include <lame/lame.h>
#define BUFFER_SIZE (7200 + 2*MPA_FRAME_SIZE + MPA_FRAME_SIZE/4)
typedef struct Mp3AudioContext {
AVClass *class;
lame_global_flags *gfp;
int stereo;
uint8_t buffer[BUFFER_SIZE];
......@@ -39,6 +42,7 @@ typedef struct Mp3AudioContext {
int *left;
int *right;
} s32_data;
int reservoir;
} Mp3AudioContext;
static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
......@@ -68,7 +72,10 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA);
}
lame_set_bWriteVbrTag(s->gfp,0);
lame_set_disable_reservoir(s->gfp, avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR ? 0 : 1);
#if FF_API_LAME_GLOBAL_OPTIONS
s->reservoir = avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR;
#endif
lame_set_disable_reservoir(s->gfp, !s->reservoir);
if (lame_init_params(s->gfp) < 0)
goto err_close;
......@@ -267,6 +274,19 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx)
return 0;
}
#define OFFSET(x) offsetof(Mp3AudioContext, x)
#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "reservoir", "Use bit reservoir.", OFFSET(reservoir), FF_OPT_TYPE_INT, { 1 }, 0, 1, AE },
{ NULL },
};
static const AVClass libmp3lame_class = {
.class_name = "libmp3lame encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_libmp3lame_encoder = {
.name = "libmp3lame",
......@@ -284,4 +304,5 @@ AVCodec ff_libmp3lame_encoder = {
AV_SAMPLE_FMT_NONE},
.supported_samplerates= sSampleRates,
.long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
.priv_class = &libmp3lame_class,
};
This diff is collapsed.
......@@ -35,6 +35,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mjpeg.h"
......@@ -98,13 +99,17 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
build_basic_mjpeg_vlc(s);
#if FF_API_MJPEG_GLOBAL_OPTS
if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
s->extern_huff = 1;
#endif
if (s->extern_huff)
{
av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
if (ff_mjpeg_decode_dht(s)) {
av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table, switching back to internal\n");
build_basic_mjpeg_vlc(s);
av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table\n");
return AVERROR_INVALIDDATA;
}
}
if (avctx->extradata_size > 9 &&
......@@ -1578,6 +1583,20 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
return 0;
}
#define OFFSET(x) offsetof(MJpegDecodeContext, x)
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "extern_huff", "Use external huffman table.", OFFSET(extern_huff), FF_OPT_TYPE_INT, { 0 }, 0, 1, VD },
{ NULL },
};
static const AVClass mjpegdec_class = {
.class_name = "MJPEG decoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_mjpeg_decoder = {
.name = "mjpeg",
.type = AVMEDIA_TYPE_VIDEO,
......@@ -1589,6 +1608,7 @@ AVCodec ff_mjpeg_decoder = {
.capabilities = CODEC_CAP_DR1,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
.priv_class = &mjpegdec_class,
};
AVCodec ff_thp_decoder = {
......
......@@ -29,6 +29,8 @@
#ifndef AVCODEC_MJPEGDEC_H
#define AVCODEC_MJPEGDEC_H
#include "libavutil/log.h"
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"
......@@ -36,6 +38,7 @@
#define MAX_COMPONENTS 4
typedef struct MJpegDecodeContext {
AVClass *class;
AVCodecContext *avctx;
GetBitContext gb;
......@@ -106,6 +109,8 @@ typedef struct MJpegDecodeContext {
uint16_t (*ljpeg_buffer)[4];
unsigned int ljpeg_buffer_size;
int extern_huff;
} MJpegDecodeContext;
int ff_mjpeg_decode_init(AVCodecContext *avctx);
......
......@@ -33,8 +33,9 @@
#include "mpeg12data.h"
#include "bytestream.h"
#include "timecode.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
static const uint8_t inv_non_linear_qscale[13] = {
0, 2, 4, 6, 8,
......@@ -142,6 +143,13 @@ static av_cold int encode_init(AVCodecContext *avctx)
if(MPV_encode_init(avctx) < 0)
return -1;
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if (avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE)
s->drop_frame_timecode = 1;
if (avctx->flags & CODEC_FLAG_SVCD_SCAN_OFFSET)
s->scan_offset = 1;
#endif
if(find_frame_rate_index(s) < 0){
if(s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num);
......@@ -174,8 +182,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
s->tc.drop = !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE);
if((avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) && s->frame_rate_index != 4){
s->drop_frame_timecode = s->tc.drop = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE);
if (s->drop_frame_timecode && s->frame_rate_index != 4) {
av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/30000 fps\n");
return -1;
}
......@@ -292,13 +300,14 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
}
put_header(s, GOP_START_CODE);
put_bits(&s->pb, 1, s->tc.drop);
put_bits(&s->pb, 1, s->drop_frame_timecode); /* drop frame flag */
/* time code : we must convert from the real frame rate to a
fake mpeg frame rate in case of low frame rate */
fps = (framerate.num + framerate.den/2)/ framerate.den;
time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start;
s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
av_assert0(s->drop_frame_timecode == s->tc.drop);
if (s->tc.drop)
time_code = ff_framenum_to_drop_timecode(time_code);
put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
......@@ -417,7 +426,7 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
put_bits(&s->pb, 1, s->progressive_frame);
put_bits(&s->pb, 1, 0); //composite_display_flag
}
if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){
if (s->scan_offset) {
int i;
put_header(s, USER_START_CODE);
......@@ -929,17 +938,38 @@ static void mpeg1_encode_block(MpegEncContext *s,
put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]);
}
static const AVClass class = {
.class_name = "mpegvideo",
.item_name = av_default_item_name,
.version = LIBAVUTIL_VERSION_INT,
.option = (const AVOption[]){
{TIMECODE_OPT(MpegEncContext,
AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)},
{NULL}
},
#define OFFSET(x) offsetof(MpegEncContext, x)
#define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
#define COMMON_OPTS\
{TIMECODE_OPT(MpegEncContext,\
AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)},\
{ "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },\
{ "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \
{ "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
static const AVOption mpeg1_options[] = {
COMMON_OPTS
{ NULL },
};
static const AVOption mpeg2_options[] = {
COMMON_OPTS
{ "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ NULL },
};
#define mpeg12_class(x)\
static const AVClass mpeg## x ##_class = {\
.class_name = "mpeg" #x "video encoder",\
.item_name = av_default_item_name,\
.option = mpeg## x ##_options,\
.version = LIBAVUTIL_VERSION_INT,\
};
mpeg12_class(1)
mpeg12_class(2)
AVCodec ff_mpeg1video_encoder = {
.name = "mpeg1video",
.type = AVMEDIA_TYPE_VIDEO,
......@@ -952,7 +982,7 @@ AVCodec ff_mpeg1video_encoder = {
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
.priv_class = &class,
.priv_class = &mpeg1_class,
};
AVCodec ff_mpeg2video_encoder = {
......@@ -967,5 +997,5 @@ AVCodec ff_mpeg2video_encoder = {
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE},
.capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.priv_class = &class,
.priv_class = &mpeg2_class,
};
......@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "mpegvideo.h"
#include "h263.h"
#include "mpeg4video.h"
......@@ -1284,6 +1286,21 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
put_bits(&s->pb, 1, 0); /* no HEC */
}
#define OFFSET(x) offsetof(MpegEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ NULL },
};
static const AVClass mpeg4enc_class = {
.class_name = "MPEG4 encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_mpeg4_encoder = {
.name = "mpeg4",
.type = AVMEDIA_TYPE_VIDEO,
......@@ -1295,4 +1312,5 @@ AVCodec ff_mpeg4_encoder = {
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
.priv_class = &mpeg4enc_class,
};
......@@ -200,7 +200,7 @@ typedef struct MotionEstContext{
* MpegEncContext.
*/
typedef struct MpegEncContext {
AVClass *av_class;
AVClass *class;
struct AVCodecContext *avctx;
/* the following parameters must be initialized before encoding */
int width, height;///< picture size. must be a multiple of 16
......@@ -645,6 +645,8 @@ typedef struct MpegEncContext {
int interlaced_dct;
int first_slice;
int first_field; ///< is 1 for the first field of a field picture 0 otherwise
int drop_frame_timecode; ///< timecode is in drop frame format.
int scan_offset; ///< reserve space for SVCD scan offset user data.
/* RTP specific */
int rtp_mode;
......
......@@ -29,6 +29,7 @@
#include "libavutil/intmath.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
......@@ -305,7 +306,10 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
s->luma_elim_threshold = avctx->luma_elim_threshold;
s->chroma_elim_threshold= avctx->chroma_elim_threshold;
s->strict_std_compliance= avctx->strict_std_compliance;
s->data_partitioning= avctx->flags & CODEC_FLAG_PART;
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if (avctx->flags & CODEC_FLAG_PART)
s->data_partitioning = 1;
#endif
s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0;
s->mpeg_quant= avctx->mpeg_quant;
s->rtp_mode= !!avctx->rtp_payload_size;
......@@ -333,11 +337,13 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|| (s->flags&CODEC_FLAG_QP_RD))
&& !s->fixed_qscale;
s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT);
s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
#endif
if(avctx->rc_max_rate && !avctx->rc_buffer_size){
av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
......@@ -390,20 +396,24 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
return -1;
}
#endif
if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
return -1;
}
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "data partitioning not supported by codec\n");
return -1;
}
#endif
if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
......@@ -461,10 +471,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
}
if(s->q_scale_type == 1){
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if(s->codec_id != CODEC_ID_MPEG2VIDEO){
av_log(avctx, AV_LOG_ERROR, "non linear quant is only available for mpeg2\n");
return -1;
}
#endif
if(avctx->qmax > 12){
av_log(avctx, AV_LOG_ERROR, "non linear quant only supports qmax <= 12 currently\n");
return -1;
......@@ -588,7 +600,6 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
s->out_format = FMT_H263;
s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
avctx->delay=0;
s->low_delay=1;
break;
......@@ -596,14 +607,18 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
s->out_format = FMT_H263;
s->h263_plus = 1;
/* Fx */
s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if (avctx->flags & CODEC_FLAG_H263P_UMV)
s->umvplus = 1;
if (avctx->flags & CODEC_FLAG_H263P_AIV)
s->alt_inter_vlc = 1;
if (avctx->flags & CODEC_FLAG_H263P_SLICE_STRUCT)
s->h263_slice_structured = 1;
#endif
s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0;
s->modified_quant= s->h263_aic;
s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
/* /Fx */
/* These are just to be sure */
......@@ -3769,6 +3784,21 @@ int dct_quantize_c(MpegEncContext *s,
return last_non_zero;
}
#define OFFSET(x) offsetof(MpegEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption h263_options[] = {
{ "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "structured_slices","Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE},
{ NULL },
};
static const AVClass h263_class = {
.class_name = "H.263 encoder",
.item_name = av_default_item_name,
.option = h263_options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_h263_encoder = {
.name = "h263",
.type = AVMEDIA_TYPE_VIDEO,
......@@ -3779,6 +3809,21 @@ AVCodec ff_h263_encoder = {
.close = MPV_encode_end,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
.priv_class = &h263_class,
};
static const AVOption h263p_options[] = {
{ "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE},
{ NULL },
};
static const AVClass h263p_class = {
.class_name = "H.263p encoder",
.item_name = av_default_item_name,
.option = h263p_options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_h263p_encoder = {
......@@ -3792,6 +3837,7 @@ AVCodec ff_h263p_encoder = {
.capabilities = CODEC_CAP_SLICE_THREADS,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
.priv_class = &h263p_class,
};
AVCodec ff_msmpeg4v2_encoder = {
......
......@@ -47,9 +47,7 @@ static av_cold int mxpeg_decode_init(AVCodecContext *avctx)
s->picture[0].reference = s->picture[1].reference = 3;
s->jpg.picture_ptr = &s->picture[0];
ff_mjpeg_decode_init(avctx);
return 0;
return ff_mjpeg_decode_init(avctx);
}
static int mxpeg_decode_app(MXpegDecodeContext *s,
......
This diff is collapsed.
......@@ -19,6 +19,8 @@
*/
#include "libavutil/intmath.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "dsputil.h"
#include "dwt.h"
......@@ -199,7 +201,7 @@ typedef struct Plane{
}Plane;
typedef struct SnowContext{
AVClass *class;
AVCodecContext *avctx;
RangeCoder c;
DSPContext dsp;
......@@ -252,6 +254,7 @@ typedef struct SnowContext{
int me_cache[ME_CACHE_SIZE];
int me_cache_generation;
slice_buffer sb;
int memc_only;
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
......@@ -3518,7 +3521,7 @@ redo_frame:
int x, y;
// int bits= put_bits_count(&s->c.pb);
if(!(avctx->flags2 & CODEC_FLAG2_MEMC_ONLY)){
if (!s->memc_only) {
//FIXME optimize
if(pict->data[plane_index]) //FIXME gray hack
for(y=0; y<h; y++){
......@@ -3676,6 +3679,20 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
#define OFFSET(x) offsetof(SnowContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ NULL },
};
static const AVClass snowenc_class = {
.class_name = "snow encoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_snow_encoder = {
.name = "snow",
.type = AVMEDIA_TYPE_VIDEO,
......@@ -3685,6 +3702,7 @@ AVCodec ff_snow_encoder = {
.encode = encode_frame,
.close = encode_end,
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
.priv_class = &snowenc_class,
};
#endif
......
......@@ -454,9 +454,6 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
v->finterpflag = get_bits1(gb);
skip_bits1(gb); // reserved
v->s.h_edge_pos = w;
v->s.v_edge_pos = h;
av_log(v->s.avctx, AV_LOG_DEBUG,
"Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
"LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n"
......@@ -475,10 +472,9 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
if(get_bits1(gb)) { //Display Info - decoding is not affected by it
int dw, dh, ar = 0;
av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n");
dw = get_bits(gb, 14) + 1;
dh = get_bits(gb, 14) + 1;
v->s.avctx->sample_aspect_ratio = av_div_q((AVRational){dw, dh}, (AVRational){w, h});
av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", dw, dh);
w = get_bits(gb, 14) + 1;
h = get_bits(gb, 14) + 1;
av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h);
if(get_bits1(gb))
ar = get_bits(gb, 4);
if(ar && ar < 14){
......@@ -487,6 +483,12 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
w = get_bits(gb, 8) + 1;
h = get_bits(gb, 8) + 1;
v->s.avctx->sample_aspect_ratio = (AVRational){w, h};
} else {
av_reduce(&v->s.avctx->sample_aspect_ratio.num,
&v->s.avctx->sample_aspect_ratio.den,
v->s.avctx->height * w,
v->s.avctx->width * h,
1<<30);
}
av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", v->s.avctx->sample_aspect_ratio.num, v->s.avctx->sample_aspect_ratio.den);
......
This diff is collapsed.
......@@ -86,5 +86,17 @@
#ifndef FF_API_X264_GLOBAL_OPTS
#define FF_API_X264_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS
#define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_LAME_GLOBAL_OPTS
#define FF_API_LAME_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_SNOW_GLOBAL_OPTS
#define FF_API_SNOW_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_MJPEG_GLOBAL_OPTS
#define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#endif /* AVCODEC_VERSION_H */
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