aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-04-19 02:24:03 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-19 02:27:53 +0200
commit7aee08997813a0e9a366b0e68fc10180339315a4 (patch)
treed848a10719003caceae0f7fe9c17005d1dbeeed4 /libavcodec
parentc96786008172f669e546ca987e7aaa3c3469be71 (diff)
parenta3040715e1f0db1af0c27566a306c4a27ad07dcd (diff)
downloadffmpeg-7aee08997813a0e9a366b0e68fc10180339315a4.tar.gz
Merge branch 'master' into oldabi
* master: (22 commits) ffmpeg:Daemon mode, add -d as first option to try it. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> ffmpeg:Fix negative verbositiy Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Include authorship information from ffmpeg-mt at Ronald S. Bultjes request. In mov and flv muxer, check aac bitstream validity. Added key_frame and pict_type to vsrc_movie Allow h264pred_init_arm.c to compile. anm decoder: move buffer allocation from decode_init() to decode_frame() vsrc_movie: fix leak in request_frame() Replace mplayerhq.hu URLs by libav.org. asfdec: Remove dead code from asf_read_close(). ptx: Use av_log_ask_for_sample() where appropriate. Merge remote-tracking branch 'ffmpeg-mt/master' 10l, commit that should have been stashed into the merge. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Update regtest checksums after revision 6001dad. Replace more FFmpeg references by Libav. ac3dec: fix processing of delta bit allocation information. vc1: fix fate-vc1 after previous commit. wmv3dec: fix playback of complex WMV3 files using simple_idct. Replace references to ffmpeg-devel with libav-devel; fix roundup URL. make av_dup_packet() more cautious on allocation failures ... Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3.c4
-rw-r--r--libavcodec/ac3dec.c4
-rw-r--r--libavcodec/anm.c9
-rw-r--r--libavcodec/arm/h264pred_init_arm.c2
-rw-r--r--libavcodec/h264.c14
-rw-r--r--libavcodec/mpegvideo.c23
-rw-r--r--libavcodec/mpegvideo.h6
-rw-r--r--libavcodec/ptx.c4
-rw-r--r--libavcodec/vc1.h1
-rw-r--r--libavcodec/vc1dec.c91
10 files changed, 93 insertions, 65 deletions
diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c
index dc7cbb3dcc..29e132f5d1 100644
--- a/libavcodec/ac3.c
+++ b/libavcodec/ac3.c
@@ -192,9 +192,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
int i, seg, delta;
- if (dba_nsegs >= 8)
+ if (dba_nsegs > 8)
return -1;
- band = 0;
+ band = band_start;
for (seg = 0; seg < dba_nsegs; seg++) {
band += dba_offsets[seg];
if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 5ef576ae0d..b2e4f81704 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1175,8 +1175,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
/* channel delta offset, len and bit allocation */
for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
if (s->dba_mode[ch] == DBA_NEW) {
- s->dba_nsegs[ch] = get_bits(gbc, 3);
- for (seg = 0; seg <= s->dba_nsegs[ch]; seg++) {
+ s->dba_nsegs[ch] = get_bits(gbc, 3) + 1;
+ for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {
s->dba_offsets[ch][seg] = get_bits(gbc, 5);
s->dba_lengths[ch][seg] = get_bits(gbc, 4);
s->dba_values[ch][seg] = get_bits(gbc, 3);
diff --git a/libavcodec/anm.c b/libavcodec/anm.c
index 5b2b9df8ea..e216c08441 100644
--- a/libavcodec/anm.c
+++ b/libavcodec/anm.c
@@ -29,6 +29,7 @@
typedef struct AnmContext {
AVFrame frame;
+ int palette[AVPALETTE_COUNT];
int x; ///< x coordinate position
} AnmContext;
@@ -44,14 +45,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
return -1;
s->frame.reference = 1;
- if (avctx->get_buffer(avctx, &s->frame) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
buf = avctx->extradata + 16*8;
for (i = 0; i < 256; i++)
- ((uint32_t*)s->frame.data[1])[i] = bytestream_get_le32(&buf);
+ s->palette[i] = bytestream_get_le32(&buf);
return 0;
}
@@ -170,6 +167,8 @@ static int decode_frame(AVCodecContext *avctx,
}
} while (buf + 1 < buf_end);
+ memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
+
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
diff --git a/libavcodec/arm/h264pred_init_arm.c b/libavcodec/arm/h264pred_init_arm.c
index 142f4b0177..5b11b7da88 100644
--- a/libavcodec/arm/h264pred_init_arm.c
+++ b/libavcodec/arm/h264pred_init_arm.c
@@ -74,7 +74,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int b
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;
}
-void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, bit_depth)
+void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth)
{
if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth);
}
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 48a2455b22..c64e6fb3f9 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -715,7 +715,7 @@ static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContex
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1);
- copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1);
+ copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1);
copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT+2, s, s1);
h->last_slice_type = h1->last_slice_type;
@@ -930,6 +930,8 @@ static void decode_postinit(H264Context *h){
if(out_of_order || pics > s->avctx->has_b_frames){
out->reference &= ~DELAYED_PIC_REF;
+ out->owner2 = s; // for frame threading, the owner must be the second field's thread
+ // or else the first thread can release the picture and reuse it unsafely
for(i=out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i+1];
}
@@ -2049,9 +2051,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
s0->first_field = FIELD_PICTURE;
}
- if((!FIELD_PICTURE || s0->first_field) && ff_h264_frame_start(h) < 0) {
- s0->first_field = 0;
- return -1;
+ if(!FIELD_PICTURE || s0->first_field) {
+ if (ff_h264_frame_start(h) < 0) {
+ s0->first_field = 0;
+ return -1;
+ }
+ } else {
+ ff_release_unused_pictures(s, 0);
}
}
if(h != h0)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 676c3ebe8a..819f58dc95 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -316,6 +316,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){
s->prev_pict_types[0]= s->dropable ? FF_B_TYPE : s->pict_type;
if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == FF_B_TYPE)
pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
+ pic->owner2 = s;
return 0;
fail: //for the FF_ALLOCZ_OR_GOTO macro
@@ -946,6 +947,21 @@ void init_vlc_rl(RLTable *rl)
}
}
+void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
+{
+ int i;
+
+ /* release non reference frames */
+ for(i=0; i<s->picture_count; i++){
+ if(s->picture[i].data[0] && !s->picture[i].reference
+ && s->picture[i].owner2 == s
+ && (remove_current || &s->picture[i] != s->current_picture_ptr)
+ /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
+ free_frame_buffer(s, &s->picture[i]);
+ }
+ }
+}
+
int ff_find_unused_picture(MpegEncContext *s, int shared){
int i;
@@ -1025,12 +1041,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
if(!s->encoding){
- /* release non reference frames */
- for(i=0; i<s->picture_count; i++){
- if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
- free_frame_buffer(s, &s->picture[i]);
- }
- }
+ ff_release_unused_pictures(s, 1);
if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL)
pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index fee75b248d..3836a6ef38 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -76,6 +76,8 @@ enum OutputFormat {
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
+struct MpegEncContext;
+
/**
* Picture.
*/
@@ -132,10 +134,9 @@ typedef struct Picture{
uint8_t *mb_mean; ///< Table for MB luminance
int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decision FIXME remove
int b_frame_score; /* */
+ struct MpegEncContext *owner2; ///< pointer to the MpegEncContext that allocated this picture
} Picture;
-struct MpegEncContext;
-
/**
* Motion estimation context.
*/
@@ -712,6 +713,7 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_mpeg_flush(AVCodecContext *avctx);
void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
+void ff_release_unused_pictures(MpegEncContext *s, int remove_current);
int ff_find_unused_picture(MpegEncContext *s, int shared);
void ff_denoise_dct(MpegEncContext *s, DCTELEM *block);
void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c
index 28df0b6f2e..426f46ce6c 100644
--- a/libavcodec/ptx.c
+++ b/libavcodec/ptx.c
@@ -51,14 +51,14 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
bytes_per_pixel = AV_RL16(buf+12) >> 3;
if (bytes_per_pixel != 2) {
- av_log(avctx, AV_LOG_ERROR, "image format is not rgb15, please report on ffmpeg-users mailing list\n");
+ av_log_ask_for_sample(avctx, "Image format is not RGB15.\n");
return -1;
}
avctx->pix_fmt = PIX_FMT_RGB555;
if (offset != 0x2c)
- av_log(avctx, AV_LOG_WARNING, "offset != 0x2c, untested due to lack of sample files\n");
+ av_log_ask_for_sample(avctx, "offset != 0x2c\n");
buf += offset;
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 261ac541f9..19be3c3452 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -218,6 +218,7 @@ typedef struct VC1Context{
int range_x, range_y; ///< MV range
uint8_t pq, altpq; ///< Current/alternate frame quantizer scale
uint8_t zz_8x8[4][64];///< Zigzag table for TT_8x8, permuted for IDCT
+ int left_blk_sh, top_blk_sh; ///< Either 3 or 0, positions of l/t in blk[]
const uint8_t* zz_8x4;///< Zigzag scan table for TT_8x4 coding mode
const uint8_t* zz_4x8;///< Zigzag scan table for TT_4x8 coding mode
/** pquant parameters */
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 41322ef726..27695f184a 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1499,16 +1499,16 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded
if(s->ac_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k] += ac_val[k];
+ block[k << v->left_blk_sh] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k + 8];
+ block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k];
- ac_val2[k + 8] = block[k << 3];
+ ac_val2[k] = block[k << v->left_blk_sh];
+ ac_val2[k + 8] = block[k << v->top_blk_sh];
}
/* scale AC coeffs */
@@ -1545,15 +1545,15 @@ not_coded:
if(s->ac_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k] = ac_val[k] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -v->pq : v->pq;
+ block[k << v->left_blk_sh] = ac_val[k] * scale;
+ if(!v->pquantizer && block[k << v->left_blk_sh])
+ block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -v->pq : v->pq;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val[k + 8] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq;
+ block[k << v->top_blk_sh] = ac_val[k + 8] * scale;
+ if(!v->pquantizer && block[k << v->top_blk_sh])
+ block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -v->pq : v->pq;
}
}
i = 63;
@@ -1680,25 +1680,25 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
- block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k] += ac_val[k];
+ block[k << v->left_blk_sh] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k + 8];
+ block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k];
- ac_val2[k + 8] = block[k << 3];
+ ac_val2[k ] = block[k << v->left_blk_sh];
+ ac_val2[k + 8] = block[k << v->top_blk_sh];
}
/* scale AC coeffs */
@@ -1740,15 +1740,15 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k] = ac_val2[k] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -mquant : mquant;
+ block[k << v->left_blk_sh] = ac_val2[k] * scale;
+ if(!v->pquantizer && block[k << v->left_blk_sh])
+ block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val2[k + 8] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
+ block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
+ if(!v->pquantizer && block[k << v->top_blk_sh])
+ block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
}
}
i = 63;
@@ -1878,25 +1878,25 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
} else { //top
for(k = 1; k < 8; k++)
- block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
+ block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
}
} else {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++)
- block[k] += ac_val[k];
+ block[k << v->left_blk_sh] += ac_val[k];
} else { //top
for(k = 1; k < 8; k++)
- block[k << 3] += ac_val[k + 8];
+ block[k << v->top_blk_sh] += ac_val[k + 8];
}
}
}
/* save AC coeffs for further prediction */
for(k = 1; k < 8; k++) {
- ac_val2[k] = block[k];
- ac_val2[k + 8] = block[k << 3];
+ ac_val2[k ] = block[k << v->left_blk_sh];
+ ac_val2[k + 8] = block[k << v->top_blk_sh];
}
/* scale AC coeffs */
@@ -1938,15 +1938,15 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
if(use_pred) {
if(dc_pred_dir) { //left
for(k = 1; k < 8; k++) {
- block[k] = ac_val2[k] * scale;
- if(!v->pquantizer && block[k])
- block[k] += (block[k] < 0) ? -mquant : mquant;
+ block[k << v->left_blk_sh] = ac_val2[k] * scale;
+ if(!v->pquantizer && block[k << v->left_blk_sh])
+ block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
}
} else { //top
for(k = 1; k < 8; k++) {
- block[k << 3] = ac_val2[k + 8] * scale;
- if(!v->pquantizer && block[k << 3])
- block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant;
+ block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
+ if(!v->pquantizer && block[k << v->top_blk_sh])
+ block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
}
}
i = 63;
@@ -3236,13 +3236,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
return -1;
if (vc1_init_common(v) < 0) return -1;
ff_vc1dsp_init(&v->vc1dsp);
- for (i = 0; i < 64; i++) {
-#define transpose(x) ((x>>3) | ((x&7)<<3))
- v->zz_8x8[0][i] = transpose(wmv1_scantable[0][i]);
- v->zz_8x8[1][i] = transpose(wmv1_scantable[1][i]);
- v->zz_8x8[2][i] = transpose(wmv1_scantable[2][i]);
- v->zz_8x8[3][i] = transpose(wmv1_scantable[3][i]);
- }
avctx->coded_width = avctx->width;
avctx->coded_height = avctx->height;
@@ -3326,6 +3319,22 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
s->mb_width = (avctx->coded_width+15)>>4;
s->mb_height = (avctx->coded_height+15)>>4;
+ if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
+ for (i = 0; i < 64; i++) {
+#define transpose(x) ((x>>3) | ((x&7)<<3))
+ v->zz_8x8[0][i] = transpose(wmv1_scantable[0][i]);
+ v->zz_8x8[1][i] = transpose(wmv1_scantable[1][i]);
+ v->zz_8x8[2][i] = transpose(wmv1_scantable[2][i]);
+ v->zz_8x8[3][i] = transpose(wmv1_scantable[3][i]);
+ }
+ v->left_blk_sh = 0;
+ v->top_blk_sh = 3;
+ } else {
+ memcpy(v->zz_8x8, wmv1_scantable, 4*64);
+ v->left_blk_sh = 3;
+ v->top_blk_sh = 0;
+ }
+
/* Allocate mb bitplanes */
v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height);
v->direct_mb_plane = av_malloc(s->mb_stride * s->mb_height);