OSDN Git Service

Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 11 Aug 2011 18:17:53 +0000 (20:17 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 11 Aug 2011 18:39:20 +0000 (20:39 +0200)
* qatar/master:
  ac3enc: add macros for option names to make them more understandable.
  ac3enc: fix 'channel_coupling' option to actually allow 'auto'.
  cavs: fix some crashes with invalid bitstreams
  ac3enc: clip coupling coordinates during calculation
  Remove incorrect info in documentation of AVCodecContext.bits_per_raw_sample.
  lavc: fix parentheses placement in avcodec_open2().

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/ac3enc.c
libavcodec/ac3enc.h
libavcodec/ac3enc_combined.c
libavcodec/avcodec.h
libavcodec/cavsdec.c

Simple merge
@@@ -65,8 -65,24 +65,25 @@@ typedef int32_t CoefType
  typedef int64_t CoefSumType;
  #endif
  
+ /* common option values */
+ #define AC3ENC_OPT_NONE            -1
+ #define AC3ENC_OPT_AUTO            -1
+ #define AC3ENC_OPT_OFF              0
+ #define AC3ENC_OPT_ON               1
+ #define AC3ENC_OPT_NOT_INDICATED    0
+ #define AC3ENC_OPT_MODE_ON          1
+ #define AC3ENC_OPT_MODE_OFF         2
+ /* specific option values */
+ #define AC3ENC_OPT_LARGE_ROOM       1
+ #define AC3ENC_OPT_SMALL_ROOM       2
+ #define AC3ENC_OPT_DOWNMIX_LTRT     1
+ #define AC3ENC_OPT_DOWNMIX_LORO     2
+ #define AC3ENC_OPT_ADCONV_STANDARD  0
+ #define AC3ENC_OPT_ADCONV_HDCD      1
  
 +#if 0
  /**
   * Encoding Options used by AVOption.
   */
index db832f1,0000000..a3f1d27
mode 100644,000000..100644
--- /dev/null
@@@ -1,100 -1,0 +1,118 @@@
 +
 +#include "libavutil/opt.h"
 +#include "libavutil/samplefmt.h"
 +#include "avcodec.h"
 +#include "ac3.h"
 +
 +typedef struct CombineContext{
 +    AVClass *av_class;                      ///< AVClass used for AVOption
 +    AC3EncOptions options;                  ///< encoding options
 +    void *ctx;
 +    AVCodec *codec;
 +}CombineContext;
 +
 +#define OFFSET(param) offsetof(CombineContext, options.param)
 +#define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 +
 +#define AC3ENC_TYPE_AC3_FIXED   0
 +#define AC3ENC_TYPE_AC3         1
 +#define AC3ENC_TYPE_EAC3        2
 +
 +#define AC3ENC_TYPE 12354
++
++/* common option values */
++#define AC3ENC_OPT_NONE            -1
++#define AC3ENC_OPT_AUTO            -1
++#define AC3ENC_OPT_OFF              0
++#define AC3ENC_OPT_ON               1
++#define AC3ENC_OPT_NOT_INDICATED    0
++#define AC3ENC_OPT_MODE_ON          1
++#define AC3ENC_OPT_MODE_OFF         2
++
++/* specific option values */
++#define AC3ENC_OPT_LARGE_ROOM       1
++#define AC3ENC_OPT_SMALL_ROOM       2
++#define AC3ENC_OPT_DOWNMIX_LTRT     1
++#define AC3ENC_OPT_DOWNMIX_LORO     2
++#define AC3ENC_OPT_ADCONV_STANDARD  0
++#define AC3ENC_OPT_ADCONV_HDCD      1
++
 +#include "ac3enc_opts_template.c"
 +
 +static AVClass ac3enc_class = { "AC-3 Encoder", av_default_item_name,
 +                                eac3_options, LIBAVUTIL_VERSION_INT };
 +
 +static av_cold AVCodec *get_codec(enum AVSampleFormat s){
 +#if CONFIG_AC3_FIXED_ENCODER
 +    if(s==AV_SAMPLE_FMT_S16) return &ff_ac3_fixed_encoder;
 +#endif
 +#if CONFIG_AC3_FLOAT_ENCODER
 +    if(s==AV_SAMPLE_FMT_FLT) return &ff_ac3_float_encoder;
 +#endif
 +    return NULL;
 +}
 +
 +
 +static av_cold int encode_init(AVCodecContext *avctx)
 +{
 +    CombineContext *c= avctx->priv_data;
 +    int ret;
 +    int offset= (uint8_t*)&c->options - (uint8_t*)c;
 +
 +    c->codec= get_codec(avctx->sample_fmt);
 +    if(!c->codec){
 +        av_log(avctx, AV_LOG_ERROR, "Unsupported sample format\n");
 +        return -1;
 +    }
 +    c->ctx= av_mallocz(c->codec->priv_data_size);
 +    memcpy((uint8_t*)c->ctx + offset, &c->options, (uint8_t*)&c->ctx - (uint8_t*)&c->options);
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    ret= c->codec->init(avctx);
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    return ret;
 +}
 +
 +static int encode_frame(AVCodecContext *avctx, unsigned char *frame,
 +                        int buf_size, void *data)
 +{
 +    CombineContext *c= avctx->priv_data;
 +    int ret;
 +
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    ret= c->codec->encode(avctx, frame, buf_size, data);
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    return ret;
 +}
 +
 +static av_cold int encode_close(AVCodecContext *avctx)
 +{
 +    CombineContext *c= avctx->priv_data;
 +    int ret;
 +
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    ret= c->codec->close(avctx);
 +    FFSWAP(void *,avctx->priv_data, c->ctx);
 +    return ret;
 +}
 +
 +AVCodec ff_ac3_encoder = {
 +    "ac3",
 +    AVMEDIA_TYPE_AUDIO,
 +    CODEC_ID_AC3,
 +    sizeof(CombineContext),
 +    encode_init,
 +    encode_frame,
 +    encode_close,
 +    NULL,
 +    .sample_fmts = (const enum AVSampleFormat[]){
 +#if CONFIG_AC3_FLOAT_ENCODER
 +        AV_SAMPLE_FMT_FLT,
 +#endif
 +#if CONFIG_AC3_FIXED_ENCODER
 +        AV_SAMPLE_FMT_S16,
 +#endif
 +        AV_SAMPLE_FMT_NONE},
 +    .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
 +    .priv_class = &ac3enc_class,
 +    .channel_layouts = ff_ac3_channel_layouts,
 +};
Simple merge
Simple merge