aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-03-26 02:42:40 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-03-26 03:06:30 +0100
commit27ef7b1bcd0577e3f5bdfc524b42b0548567be20 (patch)
treedbb243f25cf614d4951ce9352c89befb3526ed23 /libavcodec
parent0bfe349d4a3e2a98c6f4f02fb03d8585e531d850 (diff)
parenteb81cf860cbb23ece082e6a463a2c6ced8c55ead (diff)
downloadffmpeg-27ef7b1bcd0577e3f5bdfc524b42b0548567be20.tar.gz
Merge remote-tracking branch 'newdev/master'
* newdev/master: mov: set audio service type for AC-3 from bitstream mode in the 'dac3' atom. Get audio_service_type for AC-3 based on bitstream mode in the AC-3 parser and decoder, and vice-versa for the AC-3 encoder. Use audio_service_type to set stream disposition. Add APIchanges entry for audio_service_type. Add audio_service_type field to AVCodecContext for encoding and reporting of the service type in the audio bitstream. configure: in check_ld, place new -l flags before existing ones support @heading, @subheading, @subsubheading, and @subsubsection in texi2pod.pl doc: update build system documentation aacenc: indentation aacenc: fix the side calculation in search_for_ms vp8.c: rename EDGE_* to VP8_EDGE_*. Conflicts: doc/APIchanges libavcodec/avcodec.h libavcodec/version.h libavcodec/vp8.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/aac_ac3_parser.c1
-rw-r--r--libavcodec/aac_ac3_parser.h1
-rw-r--r--libavcodec/aaccoder.c4
-rw-r--r--libavcodec/ac3.h1
-rw-r--r--libavcodec/ac3_parser.c5
-rw-r--r--libavcodec/ac3dec.c5
-rw-r--r--libavcodec/ac3dec.h1
-rw-r--r--libavcodec/ac3enc.c16
-rw-r--r--libavcodec/avcodec.h20
-rw-r--r--libavcodec/eac3dec.c2
-rw-r--r--libavcodec/options.c10
-rw-r--r--libavcodec/version.h4
-rw-r--r--libavcodec/vp8.c2
13 files changed, 64 insertions, 8 deletions
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 87911619eb..6f6ed895f0 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -94,6 +94,7 @@ get_next:
avctx->channel_layout = s->channel_layout;
}
avctx->frame_size = s->samples;
+ avctx->audio_service_type = s->service_type;
}
avctx->bit_rate = s->bit_rate;
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index 75f6d4be4a..ccc387d3aa 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -49,6 +49,7 @@ typedef struct AACAC3ParseContext {
int bit_rate;
int samples;
int64_t channel_layout;
+ int service_type;
int remaining_size;
uint64_t state;
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 79723c61ef..f08b34b823 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -817,7 +817,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
int prevsc = sce->sf_idx[w*16+g];
if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) {
if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1))
- sce->sf_idx[w*16+g]--;
+ sce->sf_idx[w*16+g]--;
else //Try to make sure there is some energy in every band
sce->sf_idx[w*16+g]-=2;
}
@@ -1057,7 +1057,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe,
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
M[i] = (sce0->coeffs[start+w2*128+i]
+ sce1->coeffs[start+w2*128+i]) * 0.5;
- S[i] = sce0->coeffs[start+w2*128+i]
+ S[i] = M[i]
- sce1->coeffs[start+w2*128+i];
}
abs_pow34_v(L34, sce0->coeffs+start+w2*128, sce0->ics.swb_sizes[g]);
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 5e0b2621aa..1a8cce9a6d 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -87,6 +87,7 @@ typedef struct {
uint16_t crc1;
uint8_t sr_code;
uint8_t bitstream_id;
+ uint8_t bitstream_mode;
uint8_t channel_mode;
uint8_t lfe_on;
uint8_t frame_type;
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 301aadcd84..43feb5bc38 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -69,7 +69,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
skip_bits(gbc, 5); // skip bsid, already got it
- skip_bits(gbc, 3); // skip bitstream mode
+ hdr->bitstream_mode = get_bits(gbc, 3);
hdr->channel_mode = get_bits(gbc, 3);
if(hdr->channel_mode == AC3_CHMODE_STEREO) {
@@ -151,6 +151,9 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
hdr_info->channels = hdr.channels;
hdr_info->channel_layout = hdr.channel_layout;
hdr_info->samples = hdr.num_blocks * 256;
+ hdr_info->service_type = hdr.bitstream_mode;
+ if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
+ hdr_info->service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
if(hdr.bitstream_id>10)
hdr_info->codec_id = CODEC_ID_EAC3;
else if (hdr_info->codec_id == CODEC_ID_NONE)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 7f12d9cba0..c4365170f9 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -273,6 +273,7 @@ static int parse_frame_header(AC3DecodeContext *s)
/* get decoding parameters from header info */
s->bit_alloc_params.sr_code = hdr.sr_code;
+ s->bitstream_mode = hdr.bitstream_mode;
s->channel_mode = hdr.channel_mode;
s->channel_layout = hdr.channel_layout;
s->lfe_on = hdr.lfe_on;
@@ -1399,6 +1400,10 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
if(s->out_channels < s->channels)
s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
}
+ /* set audio service type based on bitstream mode for AC-3 */
+ avctx->audio_service_type = s->bitstream_mode;
+ if (s->bitstream_mode == 0x7 && s->channels > 1)
+ avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
/* decode the audio blocks */
channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index a5b1111123..73044d3f7c 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -79,6 +79,7 @@ typedef struct {
int bit_rate; ///< stream bit rate, in bits-per-second
int sample_rate; ///< sample frequency, in Hz
int num_blocks; ///< number of audio blocks
+ int bitstream_mode; ///< bitstream mode (bsmod)
int channel_mode; ///< channel mode (acmod)
int channel_layout; ///< channel layout
int lfe_on; ///< lfe channel in use
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 72b0291727..f41fd2da61 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1657,6 +1657,18 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
if (s->cutoff > (s->sample_rate >> 1))
s->cutoff = s->sample_rate >> 1;
+ /* validate audio service type / channels combination */
+ if ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_KARAOKE &&
+ avctx->channels == 1) ||
+ ((avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_COMMENTARY ||
+ avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_EMERGENCY ||
+ avctx->audio_service_type == AV_AUDIO_SERVICE_TYPE_VOICE_OVER)
+ && avctx->channels > 1)) {
+ av_log(avctx, AV_LOG_ERROR, "invalid audio service type for the "
+ "specified number of channels\n");
+ return AVERROR(EINVAL);
+ }
+
return 0;
}
@@ -1799,7 +1811,9 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx)
return ret;
s->bitstream_id = 8 + s->bit_alloc.sr_shift;
- s->bitstream_mode = 0; /* complete main audio service */
+ s->bitstream_mode = avctx->audio_service_type;
+ if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE)
+ s->bitstream_mode = 0x7;
s->frame_size_min = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code];
s->bits_written = 0;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5a9411f633..7ab02e635f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -546,6 +546,19 @@ enum AVLPCType {
AV_LPC_TYPE_NB , ///< Not part of ABI
};
+enum AVAudioServiceType {
+ AV_AUDIO_SERVICE_TYPE_MAIN = 0,
+ AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
+ AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
+ AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
+ AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
+ AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
+ AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
+ AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
+ AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
+ AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
+};
+
typedef struct RcOverride{
int start_frame;
int end_frame;
@@ -2876,6 +2889,13 @@ typedef struct AVCodecContext {
uint64_t vbv_delay;
/**
+ * Type of service that the audio stream conveys.
+ * - encoding: Set by user.
+ * - decoding: Set by libavcodec.
+ */
+ enum AVAudioServiceType audio_service_type;
+
+ /**
* Current statistics for PTS correction.
* - decoding: maintained and used by libavcodec, not intended to be used by user apps
* - encoding: unused
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 52d15c83f8..40f571ffc7 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -410,7 +410,7 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
/* informational metadata */
if (get_bits1(gbc)) {
- skip_bits(gbc, 3); // skip bit stream mode
+ s->bitstream_mode = get_bits(gbc, 3);
skip_bits(gbc, 2); // skip copyright bit and original bitstream bit
if (s->channel_mode == AC3_CHMODE_STEREO) {
skip_bits(gbc, 4); // skip Dolby surround and headphone mode
diff --git a/libavcodec/options.c b/libavcodec/options.c
index e4bc8a6226..47854d9d08 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -436,6 +436,16 @@ static const AVOption options[]={
{"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},
{"frame", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_FRAME, INT_MIN, INT_MAX, V|E|D, "thread_type"},
{"vbv_delay", "initial buffer fill time in periods of 27Mhz clock", 0, FF_OPT_TYPE_INT64, 0, 0, INT64_MAX},
+{"audio_service_type", "audio service type", OFFSET(audio_service_type), FF_OPT_TYPE_INT, AV_AUDIO_SERVICE_TYPE_MAIN, 0, AV_AUDIO_SERVICE_TYPE_NB-1, A|E, "audio_service_type"},
+{"ma", "Main Audio Service", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_MAIN, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"ef", "Effects", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_EFFECTS, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"vi", "Visually Impaired", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"hi", "Hearing Impaired", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"di", "Dialogue", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_DIALOGUE, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"co", "Commentary", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_COMMENTARY, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"em", "Emergency", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_EMERGENCY, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"vo", "Voice Over", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_VOICE_OVER, INT_MIN, INT_MAX, A|E, "audio_service_type"},
+{"ka", "Karaoke", 0, FF_OPT_TYPE_CONST, AV_AUDIO_SERVICE_TYPE_KARAOKE, INT_MIN, INT_MAX, A|E, "audio_service_type"},
{NULL},
};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 477d85164d..73a6f3382d 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,8 +21,8 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 114
-#define LIBAVCODEC_VERSION_MICRO 1
+#define LIBAVCODEC_VERSION_MINOR 115
+#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 073de8e25a..773500caab 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -512,7 +512,7 @@ void decode_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y)
mb->mode = VP8_MVMODE_MV;
/* If we have three distinct MVs, merge first and last if they're the same */
- if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1+VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1+VP8_EDGE_TOPLEFT]))
+ if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
/* Swap near and nearest if necessary */