summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-11 04:23:25 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-11 04:23:25 +0200
commit3602ad7ee6fe5caa402e61aa04ac695e1c46fe5e (patch)
tree5d89faee8784c9f755974a0822a3e9e90673494e /libavcodec
parent3b2d285afbd6304505a96b71877cdfda13f4565c (diff)
parent142e76f1055de5dde44696e71a5f63f2cb11dedf (diff)
Merge commit '142e76f1055de5dde44696e71a5f63f2cb11dedf'
* commit '142e76f1055de5dde44696e71a5f63f2cb11dedf': swscale: fix crash with dithering due incorrect offset calculation. matroskadec: fix stupid typo (!= -> ==) build: remove duplicates from order-only directory prerequisite list build: rework rules for things in the tools dir configure: fix --cpu=host with gcc 4.6 ARM: use const macro to define constant data in asm bitdepth: simplify FUNC/FUNCC macros dsputil: remove ff_emulated_edge_mc macro used in one place 9/10-bit: simplify clipping macros matroskadec: reindent matroskadec: defer parsing of cues element until we seek. lavc: add support for codec-specific defaults. lavc: make avcodec_alloc_context3 officially public. lavc: remove a half-working attempt at different defaults for audio/video codecs. ac3dec: add a drc_scale private option lavf: add avformat_find_stream_info() lavc: introduce avcodec_open2() as a replacement for avcodec_open(). Conflicts: Makefile libavcodec/utils.c libavformat/avformat.h libswscale/swscale_internal.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3dec.c17
-rw-r--r--libavcodec/ac3dec.h2
-rw-r--r--libavcodec/arm/fft_neon.S16
-rw-r--r--libavcodec/arm/h264idct_neon.S5
-rw-r--r--libavcodec/arm/h264pred_neon.S7
-rw-r--r--libavcodec/arm/simple_idct_neon.S5
-rw-r--r--libavcodec/arm/vp3dsp_neon.S8
-rw-r--r--libavcodec/arm/vp8_armv6.S4
-rw-r--r--libavcodec/avcodec.h78
-rw-r--r--libavcodec/bit_depth_template.c31
-rw-r--r--libavcodec/dsputil.h2
-rw-r--r--libavcodec/internal.h5
-rw-r--r--libavcodec/motion-test.c2
-rw-r--r--libavcodec/mpegvideo_enc.c4
-rw-r--r--libavcodec/options.c19
-rw-r--r--libavcodec/utils.c24
-rw-r--r--libavcodec/version.h9
-rw-r--r--libavcodec/x86/dsputil_mmx.c2
18 files changed, 178 insertions, 62 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ca6f18ff3c..6e378bb59c 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "libavutil/crc.h"
+#include "libavutil/opt.h"
#include "internal.h"
#include "aac_ac3_parser.h"
#include "ac3_parser.h"
@@ -1438,6 +1439,20 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
return 0;
}
+#define OFFSET(x) offsetof(AC3DecodeContext, x)
+#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
+static const AVOption options[] = {
+ { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {1.0}, 0.0, 1.0, PAR },
+ { NULL},
+};
+
+static const AVClass ac3_decoder_class = {
+ .class_name = "(E-)AC3 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_ac3_decoder = {
.name = "ac3",
.type = AVMEDIA_TYPE_AUDIO,
@@ -1450,6 +1465,7 @@ AVCodec ff_ac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
+ .priv_class = &ac3_decoder_class,
};
#if CONFIG_EAC3_DECODER
@@ -1465,5 +1481,6 @@ AVCodec ff_eac3_decoder = {
.sample_fmts = (const enum AVSampleFormat[]) {
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
},
+ .priv_class = &ac3_decoder_class,
};
#endif
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index 4b3e7e3d7e..8e84c18f11 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -66,6 +66,7 @@
#define AC3_FRAME_BUFFER_SIZE 32768
typedef struct {
+ AVClass *class; ///< class for AVOptions
AVCodecContext *avctx; ///< parent context
GetBitContext gbc; ///< bitstream reader
@@ -143,6 +144,7 @@ typedef struct {
///@name Dynamic range
float dynamic_range[2]; ///< dynamic range
+ float drc_scale; ///< percentage of dynamic range compression to be applied
///@}
///@name Bandwidth
diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S
index 1db7abd146..fd76edcd15 100644
--- a/libavcodec/arm/fft_neon.S
+++ b/libavcodec/arm/fft_neon.S
@@ -349,9 +349,7 @@ function ff_fft_permute_neon, export=1
pop {r4,pc}
endfunc
- .section .rodata
- .align 4
-fft_tab_neon:
+const fft_tab_neon
.word fft4_neon
.word fft8_neon
.word fft16_neon
@@ -367,8 +365,12 @@ fft_tab_neon:
.word fft16384_neon
.word fft32768_neon
.word fft65536_neon
-ELF .size fft_tab_neon, . - fft_tab_neon
+endconst
- .align 4
-pmmp: .float +1.0, -1.0, -1.0, +1.0
-mppm: .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
+const pmmp, align=4
+ .float +1.0, -1.0, -1.0, +1.0
+endconst
+
+const mppm, align=4
+ .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
+endconst
diff --git a/libavcodec/arm/h264idct_neon.S b/libavcodec/arm/h264idct_neon.S
index 6ea56587b8..8cf9bd8b66 100644
--- a/libavcodec/arm/h264idct_neon.S
+++ b/libavcodec/arm/h264idct_neon.S
@@ -383,8 +383,8 @@ function ff_h264_idct8_add4_neon, export=1
pop {r4-r8,pc}
endfunc
- .section .rodata
-scan8: .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
+const scan8
+ .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
.byte 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8
.byte 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8
.byte 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8
@@ -396,3 +396,4 @@ scan8: .byte 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
.byte 6+11*8, 7+11*8, 6+12*8, 7+12*8
.byte 4+13*8, 5+13*8, 4+14*8, 5+14*8
.byte 6+13*8, 7+13*8, 6+14*8, 7+14*8
+endconst
diff --git a/libavcodec/arm/h264pred_neon.S b/libavcodec/arm/h264pred_neon.S
index 63c96ee725..0dac20b4a0 100644
--- a/libavcodec/arm/h264pred_neon.S
+++ b/libavcodec/arm/h264pred_neon.S
@@ -166,12 +166,9 @@ function ff_pred16x16_plane_neon, export=1
bx lr
endfunc
- .section .rodata
- .align 4
-p16weight:
+const p16weight, align=4
.short 1,2,3,4,5,6,7,8
-
- .text
+endconst
function ff_pred8x8_hor_neon, export=1
sub r2, r0, #1
diff --git a/libavcodec/arm/simple_idct_neon.S b/libavcodec/arm/simple_idct_neon.S
index 64a7fbf13a..5df8f6e4fc 100644
--- a/libavcodec/arm/simple_idct_neon.S
+++ b/libavcodec/arm/simple_idct_neon.S
@@ -243,10 +243,9 @@ function idct_col4_st8_neon
bx lr
endfunc
- .section .rodata
- .align 4
-idct_coeff_neon:
+const idct_coeff_neon, align=4
.short W1, W2, W3, W4, W5, W6, W7, W4c
+endconst
.macro idct_start data
push {r4-r7, lr}
diff --git a/libavcodec/arm/vp3dsp_neon.S b/libavcodec/arm/vp3dsp_neon.S
index d97ed3d21d..ae3e40201a 100644
--- a/libavcodec/arm/vp3dsp_neon.S
+++ b/libavcodec/arm/vp3dsp_neon.S
@@ -20,11 +20,9 @@
#include "asm.S"
-.section .rodata
-.align 4
-
-vp3_idct_constants:
+const vp3_idct_constants, align=4
.short 64277, 60547, 54491, 46341, 36410, 25080, 12785
+endconst
#define xC1S7 d0[0]
#define xC2S6 d0[1]
@@ -34,8 +32,6 @@ vp3_idct_constants:
#define xC6S2 d1[1]
#define xC7S1 d1[2]
-.text
-
.macro vp3_loop_filter
vsubl.u8 q3, d18, d17
vsubl.u8 q2, d16, d19
diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S
index b995360e0c..8a3beb9fbb 100644
--- a/libavcodec/arm/vp8_armv6.S
+++ b/libavcodec/arm/vp8_armv6.S
@@ -240,9 +240,9 @@ A orrcs r8, r8, r10, lsl r6
b 5b
endfunc
- .section .rodata
-zigzag_scan:
+const zigzag_scan
.byte 0, 2, 8, 16
.byte 10, 4, 6, 12
.byte 18, 24, 26, 20
.byte 14, 22, 28, 30
+endconst
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7e9348adef..80be7318e0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -30,6 +30,7 @@
#include "libavutil/samplefmt.h"
#include "libavutil/avutil.h"
#include "libavutil/cpu.h"
+#include "libavutil/dict.h"
#include "libavutil/log.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
@@ -2590,13 +2591,16 @@ typedef struct AVCodecContext {
int request_channels;
#endif
+#if FF_API_DRC_SCALE
/**
* Percentage of dynamic range compression to be applied by the decoder.
* The default value is 1.0, corresponding to full compression.
* - encoding: unused
* - decoding: Set by user.
+ * @deprecated use AC3 decoder private option instead.
*/
- float drc_scale;
+ attribute_deprecated float drc_scale;
+#endif
/**
* opaque 64bit number (generally a PTS) that will be reordered and
@@ -2916,6 +2920,8 @@ typedef struct AVProfile {
const char *name; ///< short name for the profile
} AVProfile;
+typedef struct AVCodecDefault AVCodecDefault;
+
/**
* AVCodec.
*/
@@ -2978,6 +2984,11 @@ typedef struct AVCodec {
*/
int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
/** @} */
+
+ /**
+ * Private codec-specific defaults.
+ */
+ const AVCodecDefault *defaults;
} AVCodec;
/**
@@ -3593,21 +3604,38 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
* we WILL change its arguments and name a few times! */
int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
+#if FF_API_ALLOC_CONTEXT
/**
* Allocate an AVCodecContext and set its fields to default values. The
* resulting struct can be deallocated by simply calling av_free().
*
* @return An AVCodecContext filled with default values or NULL on failure.
* @see avcodec_get_context_defaults
+ *
+ * @deprecated use avcodec_alloc_context3()
*/
+attribute_deprecated
AVCodecContext *avcodec_alloc_context(void);
/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
* we WILL change its arguments and name a few times! */
+attribute_deprecated
AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
+#endif
-/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
- * we WILL change its arguments and name a few times! */
+/**
+ * Allocate an AVCodecContext and set its fields to default values. The
+ * resulting struct can be deallocated by simply calling av_free().
+ *
+ * @param codec if non-NULL, allocate private data and initialize defaults
+ * for the given codec. It is illegal to then call avcodec_open()
+ * with a different codec.
+ *
+ * @return An AVCodecContext filled with default values or NULL on failure.
+ * @see avcodec_get_context_defaults
+ *
+ * @deprecated use avcodec_alloc_context3()
+ */
AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
/**
@@ -3617,7 +3645,7 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
* can use this AVCodecContext to decode/encode video/audio data.
*
* @param dest target codec context, should be initialized with
- * avcodec_alloc_context(), but otherwise uninitialized
+ * avcodec_alloc_context3(), but otherwise uninitialized
* @param src source codec context
* @return AVERROR() on error (e.g. memory allocation error), 0 on success
*/
@@ -3687,6 +3715,7 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
//FIXME func typedef
+#if FF_API_AVCODEC_OPEN
/**
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
* function the context has to be allocated.
@@ -3703,7 +3732,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
* if (!codec)
* exit(1);
*
- * context = avcodec_alloc_context();
+ * context = avcodec_alloc_context3(codec);
*
* if (avcodec_open(context, codec) < 0)
* exit(1);
@@ -3712,9 +3741,46 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
* @param avctx The context which will be set up to use the given codec.
* @param codec The codec to use within the context.
* @return zero on success, a negative value on error
- * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
+ * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
+ *
+ * @deprecated use avcodec_open2
*/
+attribute_deprecated
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
+#endif
+
+/**
+ * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
+ * function the context has to be allocated with avcodec_alloc_context().
+ *
+ * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
+ * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
+ * retrieving a codec.
+ *
+ * @warning This function is not thread safe!
+ *
+ * @code
+ * avcodec_register_all();
+ * av_dict_set(&opts, "b", "2.5M", 0);
+ * codec = avcodec_find_decoder(CODEC_ID_H264);
+ * if (!codec)
+ * exit(1);
+ *
+ * context = avcodec_alloc_context();
+ *
+ * if (avcodec_open(context, codec, opts) < 0)
+ * exit(1);
+ * @endcode
+ *
+ * @param avctx The context to initialize.
+ * @param options A dictionary filled with AVCodecContext and codec-private options.
+ * On return this object will be filled with options that were not found.
+ *
+ * @return zero on success, a negative value on error
+ * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
+ * av_dict_set(), av_opt_find().
+ */
+int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
/**
* Decode the audio frame of size avpkt->size from avpkt->data into samples.
diff --git a/libavcodec/bit_depth_template.c b/libavcodec/bit_depth_template.c
index c0a6eafe89..9071ec2a35 100644
--- a/libavcodec/bit_depth_template.c
+++ b/libavcodec/bit_depth_template.c
@@ -43,15 +43,6 @@
# undef PIXEL_SPLAT_X4
#else
# define AVCODEC_H264_HIGH_DEPTH_H
-# define CLIP_PIXEL(depth)\
- static inline uint16_t av_clip_pixel_ ## depth (int p)\
- {\
- const int pixel_max = (1 << depth)-1;\
- return (p & ~pixel_max) ? (-p)>>31 & pixel_max : p;\
- }
-
-CLIP_PIXEL( 9)
-CLIP_PIXEL(10)
#endif
#if BIT_DEPTH > 8
@@ -70,6 +61,9 @@ CLIP_PIXEL(10)
# define AV_WN4P AV_WN64
# define AV_WN4PA AV_WN64A
# define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
+
+# define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
+# define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
#else
# define pixel uint8_t
# define pixel2 uint16_t
@@ -86,21 +80,12 @@ CLIP_PIXEL(10)
# define AV_WN4P AV_WN32
# define AV_WN4PA AV_WN32A
# define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
-#endif
-#if BIT_DEPTH == 8
# define av_clip_pixel(a) av_clip_uint8(a)
# define CLIP(a) cm[a]
-# define FUNC(a) a ## _8
-# define FUNCC(a) a ## _8_c
-#elif BIT_DEPTH == 9
-# define av_clip_pixel(a) av_clip_pixel_9(a)
-# define CLIP(a) av_clip_pixel_9(a)
-# define FUNC(a) a ## _9
-# define FUNCC(a) a ## _9_c
-#elif BIT_DEPTH == 10
-# define av_clip_pixel(a) av_clip_pixel_10(a)
-# define CLIP(a) av_clip_pixel_10(a)
-# define FUNC(a) a ## _10
-# define FUNCC(a) a ## _10_c
#endif
+
+#define FUNC3(a, b, c) a ## _ ## b ## c
+#define FUNC2(a, b, c) FUNC3(a, b, c)
+#define FUNC(a) FUNC2(a, BIT_DEPTH,)
+#define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 401a87a29b..2579bea91b 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -211,8 +211,6 @@ EMULATED_EDGE(8)
EMULATED_EDGE(9)
EMULATED_EDGE(10)
-#define ff_emulated_edge_mc ff_emulated_edge_mc_8
-
void ff_add_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
void ff_put_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
void ff_put_signed_pixels_clamped_c(const DCTELEM *block, uint8_t *dest, int linesize);
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 24aca6b28b..75d7f37716 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -27,6 +27,11 @@
#include <stdint.h>
#include "avcodec.h"
+struct AVCodecDefault {
+ const uint8_t *key;
+ const uint8_t *value;
+};
+
/**
* Determine whether pix_fmt is a hardware accelerated format.
*/
diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c
index 994b262bc0..85ea1045b4 100644
--- a/libavcodec/motion-test.c
+++ b/libavcodec/motion-test.c
@@ -144,7 +144,7 @@ int main(int argc, char **argv)
printf("ffmpeg motion test\n");
- ctx = avcodec_alloc_context();
+ ctx = avcodec_alloc_context3(NULL);
ctx->dsp_mask = AV_CPU_FLAG_FORCE;
dsputil_init(&cctx, ctx);
for (c = 0; c < flags_size; c++) {
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d32b9e63fb..4c47d41808 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -944,7 +944,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
static int estimate_best_b_count(MpegEncContext *s){
AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
- AVCodecContext *c= avcodec_alloc_context();
+ AVCodecContext *c = avcodec_alloc_context3(NULL);
AVFrame input[FF_MAX_B_FRAMES+2];
const int scale= s->avctx->brd_scale;
int i, j, out_size, p_lambda, b_lambda, lambda2;
@@ -973,7 +973,7 @@ static int estimate_best_b_count(MpegEncContext *s){
c->time_base= s->avctx->time_base;
c->max_b_frames= s->max_b_frames;
- if (avcodec_open(c, codec) < 0)
+ if (avcodec_open2(c, codec, NULL) < 0)
return -1;
for(i=0; i<s->max_b_frames+2; i++){
diff --git a/libavcodec/options.c b/libavcodec/options.c
index b6ad5d8763..74e60fb67f 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -25,6 +25,8 @@
*/
#include "avcodec.h"
+#include "internal.h"
+#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include <float.h> /* FLT_MIN, FLT_MAX */
@@ -69,7 +71,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, i
static const AVOption options[]={
{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, V|E},
-{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = 64*1000 }, INT_MIN, INT_MAX, A|E},
+{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|E},
{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E},
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"},
{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"},
@@ -413,7 +415,9 @@ static const AVOption options[]={
#if FF_API_REQUEST_CHANNELS
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D},
#endif
+#if FF_API_DRC_SCALE
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0.0, 1.0, A|D},
+#endif
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"},
{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"},
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
@@ -522,6 +526,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
av_opt_set_defaults(s->priv_data);
}
}
+ if (codec && codec->defaults) {
+ int ret;
+ AVCodecDefault *d = codec->defaults;
+ while (d->key) {
+ ret = av_set_string3(s, d->key, d->value, 0, NULL);
+ av_assert0(ret >= 0);
+ d++;
+ }
+ }
return 0;
}
@@ -538,6 +551,7 @@ AVCodecContext *avcodec_alloc_context3(AVCodec *codec){
return avctx;
}
+#if FF_API_ALLOC_CONTEXT
AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
@@ -547,14 +561,17 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
return avctx;
}
+#endif
void avcodec_get_context_defaults(AVCodecContext *s){
avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN);
}
+#if FF_API_ALLOC_CONTEXT
AVCodecContext *avcodec_alloc_context(void){
return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
}
+#endif
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0c84965883..356e21f541 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -32,6 +32,7 @@
#include "libavutil/audioconvert.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
+#include "libavutil/dict.h"
#include "avcodec.h"
#include "dsputil.h"
#include "libavutil/opt.h"
@@ -485,9 +486,20 @@ static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
sub->pts = AV_NOPTS_VALUE;
}
+#if FF_API_AVCODEC_OPEN
int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
{
+ return avcodec_open2(avctx, codec, NULL);
+}
+#endif
+
+int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
+{
int ret = 0;
+ AVDictionary *tmp = NULL;
+
+ if (options)
+ av_dict_copy(&tmp, *options, 0);
/* If there is a user-supplied mutex locking routine, call it. */
if (ff_lockmgr_cb) {
@@ -514,14 +526,18 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
ret = AVERROR(ENOMEM);
goto end;
}
- if(codec->priv_class){ //this can be droped once all user apps use avcodec_get_context_defaults3()
+ if (codec->priv_class) {
*(AVClass**)avctx->priv_data= codec->priv_class;
av_opt_set_defaults(avctx->priv_data);
}
}
+ if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp) < 0))
+ goto free_and_end;
} else {
avctx->priv_data = NULL;
}
+ if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
+ goto free_and_end;
if(avctx->coded_width && avctx->coded_height)
avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
@@ -640,8 +656,14 @@ end:
if (ff_lockmgr_cb) {
(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
}
+ if (options) {
+ av_dict_free(options);
+ *options = tmp;
+ }
+
return ret;
free_and_end:
+ av_dict_free(&tmp);
av_freep(&avctx->priv_data);
avctx->codec= NULL;
goto end;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 100c06dfe6..de67bd40fc 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -68,5 +68,14 @@
#ifndef FF_API_GET_PIX_FMT_NAME
#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_ALLOC_CONTEXT
+#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_AVCODEC_OPEN
+#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_DRC_SCALE
+#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
#endif /* AVCODEC_VERSION_H */
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
index 640048644c..c544b43d38 100644
--- a/libavcodec/x86/dsputil_mmx.c
+++ b/libavcodec/x86/dsputil_mmx.c
@@ -1783,7 +1783,7 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
{
gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
- width, height, &ff_emulated_edge_mc);
+ width, height, &ff_emulated_edge_mc_8);
}
#endif