diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-22 00:48:38 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-22 01:51:53 +0100 |
commit | 52c522c72090233edeeb0486a9bd8bee925a710a (patch) | |
tree | 23f091bb1fb649e8358d01516670360c13cb08e6 /libavcodec | |
parent | a40f43db647bfacafbd1e27a4cd5f6134c6e6c53 (diff) | |
parent | e9dc92012773aab5f51d8d37eb14564988c5f217 (diff) | |
download | ffmpeg-52c522c72090233edeeb0486a9bd8bee925a710a.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (27 commits)
asfdec: add side data to ASFStream packet instead of output packet.
idroqdec: set AVFMTCTX_NOHEADER and create streams as they occur.
nellymoserdec: Indicate that the decoder can handle changed parameters
libavcodec: Apply parameter change side data when decoding audio
flvdec: Add param change side data if the sample rate or channels have changed
libavformat: Add a utility function for adding parameter change side data
libavcodec: Define a side data type for parameter changes
aacdec: Handle new extradata passed as side data
flvdec: Export new AAC/H.264 extradata as side data on the next packet
libavcodec: Define a side data type for new extradata
flacdec: skip all track indices at once instead of looping.
mxf: Add PictureEssenceCoding UL for V210.
mxfdec: consider QuantizationBits between 17 and 24 to be pcm_s24*
mxfenc: Add support for MPEG-2 MP@HL-14 in mxf container.
mxf: H.264/MPEG-4 AVC Intra support
configure: Show whether the safe bitstream reader is enabled
x86: Tighten register constraints for decode_significance*_x86.
Replace Subversion revisions in comments by Git hashes.
h264_cabac: synchronize decode_significance_*_x86 conditionals
w32threads: wait for the waked thread in pthread_cond_signal.
...
Conflicts:
libavcodec/avcodec.h
libavcodec/version.h
libavformat/flvdec.c
libavformat/utils.c
tests/ref/lavfi/pixdesc
tests/ref/lavfi/pixfmts_copy
tests/ref/lavfi/pixfmts_null
tests/ref/lavfi/pixfmts_scale
tests/ref/lavfi/pixfmts_vflip
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aacdec.c | 43 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 27 | ||||
-rw-r--r-- | libavcodec/h264.c | 8 | ||||
-rw-r--r-- | libavcodec/h264_cabac.c | 2 | ||||
-rw-r--r-- | libavcodec/lpc.c | 5 | ||||
-rw-r--r-- | libavcodec/nellymoserdec.c | 2 | ||||
-rw-r--r-- | libavcodec/utils.c | 44 | ||||
-rw-r--r-- | libavcodec/version.h | 4 | ||||
-rw-r--r-- | libavcodec/w32pthreads.h | 16 | ||||
-rw-r--r-- | libavcodec/wmalosslessdec.c | 5 | ||||
-rw-r--r-- | libavcodec/x86/h264_i386.h | 4 |
11 files changed, 126 insertions, 34 deletions
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 3183ff2373..c9ca0a66a2 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -722,16 +722,13 @@ static void decode_ltp(AACContext *ac, LongTermPrediction *ltp, /** * Decode Individual Channel Stream info; reference: table 4.6. - * - * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. */ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, - GetBitContext *gb, int common_window) + GetBitContext *gb) { if (get_bits1(gb)) { av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); - memset(ics, 0, sizeof(IndividualChannelStream)); - return -1; + return AVERROR_INVALIDDATA; } ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = get_bits(gb, 2); @@ -766,13 +763,11 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, if (ics->predictor_present) { if (ac->m4ac.object_type == AOT_AAC_MAIN) { if (decode_prediction(ac, ics, gb)) { - memset(ics, 0, sizeof(IndividualChannelStream)); - return -1; + return AVERROR_INVALIDDATA; } } else if (ac->m4ac.object_type == AOT_AAC_LC) { av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); - memset(ics, 0, sizeof(IndividualChannelStream)); - return -1; + return AVERROR_INVALIDDATA; } else { if ((ics->ltp.present = get_bits(gb, 1))) decode_ltp(ac, &ics->ltp, gb, ics->max_sfb); @@ -784,8 +779,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, av_log(ac->avctx, AV_LOG_ERROR, "Number of scalefactor bands in group (%d) exceeds limit (%d).\n", ics->max_sfb, ics->num_swb); - memset(ics, 0, sizeof(IndividualChannelStream)); - return -1; + return AVERROR_INVALIDDATA; } return 0; @@ -1390,8 +1384,8 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, global_gain = get_bits(gb, 8); if (!common_window && !scale_flag) { - if (decode_ics_info(ac, ics, gb, 0) < 0) - return -1; + if (decode_ics_info(ac, ics, gb) < 0) + return AVERROR_INVALIDDATA; } if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0) @@ -1507,8 +1501,8 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) common_window = get_bits1(gb); if (common_window) { - if (decode_ics_info(ac, &cpe->ch[0].ics, gb, 1)) - return -1; + if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) + return AVERROR_INVALIDDATA; i = cpe->ch[1].ics.use_kb_window[0]; cpe->ch[1].ics = cpe->ch[0].ics; cpe->ch[1].ics.use_kb_window[1] = i; @@ -2282,12 +2276,31 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, static int aac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AACContext *ac = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; GetBitContext gb; int buf_consumed; int buf_offset; int err; + int new_extradata_size; + const uint8_t *new_extradata = av_packet_get_side_data(avpkt, + AV_PKT_DATA_NEW_EXTRADATA, + &new_extradata_size); + + if (new_extradata) { + av_free(avctx->extradata); + avctx->extradata = av_mallocz(new_extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + avctx->extradata_size = new_extradata_size; + memcpy(avctx->extradata, new_extradata, new_extradata_size); + if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, + avctx->extradata, + avctx->extradata_size*8, 1) < 0) + return AVERROR_INVALIDDATA; + } init_get_bits(&gb, buf, buf_size * 8); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0b9405ff4d..90719dc9ee 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -792,6 +792,10 @@ typedef struct RcOverride{ */ #define CODEC_CAP_SLICE_THREADS 0x2000 /** + * Codec supports changed parameters at any point. + */ +#define CODEC_CAP_PARAM_CHANGE 0x4000 +/** * Codec is lossless. */ #define CODEC_CAP_LOSSLESS 0x80000000 @@ -877,6 +881,8 @@ typedef struct AVPanScan{ enum AVPacketSideDataType { AV_PKT_DATA_PALETTE, + AV_PKT_DATA_NEW_EXTRADATA, + AV_PKT_DATA_PARAM_CHANGE, }; typedef struct AVPacket { @@ -946,6 +952,27 @@ typedef struct AVPacket { #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted /** + * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: + * u32le param_flags + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) + * s32le channel_count + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) + * u64le channel_layout + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) + * s32le sample_rate + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) + * s32le width + * s32le height + */ + +enum AVSideDataParamChangeFlags { + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, +}; + +/** * Audio Video Frame. * New fields can be added to the end of AVFRAME with minor version * bumps. Similarly fields that are marked as to be only accessed by diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 652a4e9ff9..9978188620 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4195,13 +4195,13 @@ int main(void){ s= show_bits(&gb, 24); - START_TIMER + {START_TIMER j= get_ue_golomb(&gb); if(j != i){ printf("mismatch! at %d (%d should be %d) bits:%6X\n", i, j, i, s); // return -1; } - STOP_TIMER("get_ue_golomb"); + STOP_TIMER("get_ue_golomb");} } @@ -4220,13 +4220,13 @@ int main(void){ s= show_bits(&gb, 24); - START_TIMER + {START_TIMER j= get_se_golomb(&gb); if(j != i - COUNT/2){ printf("mismatch! at %d (%d should be %d) bits:%6X\n", i, j, i, s); // return -1; } - STOP_TIMER("get_se_golomb"); + STOP_TIMER("get_se_golomb");} } printf("Testing RBSP\n"); diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 0b33e30808..5482294afd 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -1657,7 +1657,7 @@ decode_cabac_residual_internal(H264Context *h, DCTELEM *block, index[coeff_count++] = last;\ } const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; -#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) +#if ARCH_X86 && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base, sig_off); } else { diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index c27208823d..3401226d0f 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -35,8 +35,9 @@ static void lpc_apply_welch_window_c(const int32_t *data, int len, double w; double c; - assert(!(len&1)); //the optimization in r11881 does not support odd len - //if someone wants odd len extend the change in r11881 + /* The optimization in commit fa4ed8c does not support odd len. + * If someone wants odd len extend that change. */ + assert(!(len & 1)); n2 = (len >> 1); c = 2.0 / (len - 1.0); diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 3386b8241e..c2e7cda461 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -226,7 +226,7 @@ AVCodec ff_nellymoser_decoder = { .init = decode_init, .close = decode_end, .decode = decode_tag, - .capabilities = CODEC_CAP_DR1, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE, .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 03e367f4c2..7d30f7631f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -41,6 +41,7 @@ #include "thread.h" #include "audioconvert.h" #include "internal.h" +#include "bytestream.h" #include <stdlib.h> #include <stdarg.h> #include <limits.h> @@ -1028,6 +1029,47 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa } #endif +static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt) +{ + int size = 0; + const uint8_t *data; + uint32_t flags; + + if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE)) + return; + + data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size); + if (!data || size < 4) + return; + flags = bytestream_get_le32(&data); + size -= 4; + if (size < 4) /* Required for any of the changes */ + return; + if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) { + avctx->channels = bytestream_get_le32(&data); + size -= 4; + } + if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) { + if (size < 8) + return; + avctx->channel_layout = bytestream_get_le64(&data); + size -= 8; + } + if (size < 4) + return; + if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) { + avctx->sample_rate = bytestream_get_le32(&data); + size -= 4; + } + if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) { + if (size < 8) + return; + avctx->width = bytestream_get_le32(&data); + avctx->height = bytestream_get_le32(&data); + size -= 8; + } +} + int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, @@ -1044,6 +1086,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) { av_packet_split_side_data(avpkt); + apply_param_change(avctx, avpkt); + avctx->pkt = avpkt; ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt); if (ret >= 0 && *got_frame_ptr) { diff --git a/libavcodec/version.h b/libavcodec/version.h index 360068a95f..5d4807cdbe 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,8 +21,8 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 46 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 47 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/w32pthreads.h b/libavcodec/w32pthreads.h index 2d1470c5ee..3cdbc2c343 100644 --- a/libavcodec/w32pthreads.h +++ b/libavcodec/w32pthreads.h @@ -139,7 +139,7 @@ static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); if (!win32_cond->semaphore) return; - win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL); + win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL); if (!win32_cond->waiters_done) return; @@ -204,11 +204,10 @@ static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) /* non native condition variables */ pthread_mutex_lock(&win32_cond->mtx_broadcast); - pthread_mutex_unlock(&win32_cond->mtx_broadcast); - pthread_mutex_lock(&win32_cond->mtx_waiter_count); win32_cond->waiter_count++; pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + pthread_mutex_unlock(&win32_cond->mtx_broadcast); // unlock the external mutex pthread_mutex_unlock(mutex); @@ -216,7 +215,7 @@ static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) pthread_mutex_lock(&win32_cond->mtx_waiter_count); win32_cond->waiter_count--; - last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast; + last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast; pthread_mutex_unlock(&win32_cond->mtx_waiter_count); if (last_waiter) @@ -235,13 +234,20 @@ static void pthread_cond_signal(pthread_cond_t *cond) return; } + pthread_mutex_lock(&win32_cond->mtx_broadcast); + /* non-native condition variables */ pthread_mutex_lock(&win32_cond->mtx_waiter_count); have_waiter = win32_cond->waiter_count; pthread_mutex_unlock(&win32_cond->mtx_waiter_count); - if (have_waiter) + if (have_waiter) { ReleaseSemaphore(win32_cond->semaphore, 1, NULL); + WaitForSingleObject(win32_cond->waiters_done, INFINITE); + ResetEvent(win32_cond->waiters_done); + } + + pthread_mutex_unlock(&win32_cond->mtx_broadcast); } static void w32thread_init(void) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 2b32bccba1..0af01de390 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1338,6 +1338,7 @@ static int decode_packet(AVCodecContext *avctx, *data_size = 0; if (s->packet_done || s->packet_loss) { + int seekable_frame_in_packet, spliced_packet; s->packet_done = 0; /** sanity check for the buffer length */ @@ -1351,8 +1352,8 @@ static int decode_packet(AVCodecContext *avctx, /** parse packet header */ init_get_bits(gb, buf, s->buf_bit_size); packet_sequence_number = get_bits(gb, 4); - int seekable_frame_in_packet = get_bits1(gb); - int spliced_packet = get_bits1(gb); + seekable_frame_in_packet = get_bits1(gb); + spliced_packet = get_bits1(gb); /** get number of bits that need to be added to the previous frame */ num_bits_prev_frame = get_bits(gb, s->log2_frame_size); diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h index 089762b1dd..0bc6a611f1 100644 --- a/libavcodec/x86/h264_i386.h +++ b/libavcodec/x86/h264_i386.h @@ -36,7 +36,7 @@ //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //as that would make optimization work hard) -#if HAVE_6REGS && !defined(BROKEN_RELOCATIONS) +#if HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index, x86_reg last_off){ @@ -144,6 +144,6 @@ static int decode_significance_8x8_x86(CABACContext *c, ); return coeff_count; } -#endif /* HAVE_6REGS && !defined(BROKEN_RELOCATIONS) */ +#endif /* HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ #endif /* AVCODEC_X86_H264_I386_H */ |