From 3f5aa7dfa64c8757e5eef7b1bf870ec754e40f96 Mon Sep 17 00:00:00 2001 From: Cheng Sun Date: Sat, 26 Nov 2011 16:36:50 -0800 Subject: pthread: track thread existence in a separate variable. This fixes a compile error on mingw32 when using p->thread directly (as if it were a pointer) to track thread existence, because the type is opaque and may be a non-pointer. Signed-off-by: Ronald S. Bultje --- libavcodec/pthread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index dae28e6f5e..21e32b59ea 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -70,6 +70,7 @@ typedef struct PerThreadContext { struct FrameThreadContext *parent; pthread_t thread; + int thread_init; pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread. pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change. pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish. @@ -651,7 +652,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) pthread_cond_signal(&p->input_cond); pthread_mutex_unlock(&p->mutex); - if (p->thread) + if (p->thread_init) pthread_join(p->thread, NULL); if (codec->close) @@ -756,7 +757,8 @@ static int frame_thread_init(AVCodecContext *avctx) if (err) goto error; - pthread_create(&p->thread, NULL, frame_worker_thread, p); + if (!pthread_create(&p->thread, NULL, frame_worker_thread, p)) + p->thread_init = 1; } return 0; -- cgit v1.2.3 From 498605b4ad64e63990c4a94de9ff614a3c770d01 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 26 Nov 2011 13:23:39 +0100 Subject: vc1: select interlaced scan table by FCM element Interlaced videos can contain progressive frames too and now wrong scantable is selected for them. Signed-off-by: Ronald S. Bultje --- libavcodec/vc1dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 7a65f31826..c479c08479 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3293,7 +3293,7 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, i += skip; if (i > 63) break; - if (!v->interlace) + if (!v->fcm) idx = v->zz_8x8[0][i++]; else idx = v->zzi_8x8[i++]; @@ -3321,7 +3321,7 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, i += skip; if (i > 15) break; - if (!v->interlace) + if (!v->fcm) idx = ff_vc1_simple_progressive_4x4_zz[i++]; else idx = ff_vc1_adv_interlaced_4x4_zz[i++]; @@ -3348,7 +3348,7 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, i += skip; if (i > 31) break; - if (!v->interlace) + if (!v->fcm) idx = v->zz_8x4[i++] + off; else idx = ff_vc1_adv_interlaced_8x4_zz[i++] + off; @@ -3375,7 +3375,7 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, i += skip; if (i > 31) break; - if (!v->interlace) + if (!v->fcm) idx = v->zz_4x8[i++] + off; else idx = ff_vc1_adv_interlaced_4x8_zz[i++] + off; -- cgit v1.2.3 From f11b0e95434937aba4ec652d1fc08cc17a71e151 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Sat, 26 Nov 2011 19:40:34 -0800 Subject: wmavoice: Make format string match variable type. --- libavcodec/wmavoice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec') diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 61258ba1ce..d6d4cb2963 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -1795,7 +1795,7 @@ static int synth_superframe(AVCodecContext *ctx, out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt); if (*data_size < out_size) { av_log(ctx, AV_LOG_ERROR, - "Output buffer too small (%d given - %zu needed)\n", + "Output buffer too small (%d given - %d needed)\n", *data_size, out_size); return -1; } -- cgit v1.2.3 From 0df5e869cb9fc4eb6f7aacdf40920b0b87ce4db7 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 27 Nov 2011 13:07:19 -0500 Subject: mpegaudio: do not use init_static_data() for initializing tables. It is called once for each mpegaudio codec that is registered, which adds significant overhead. --- libavcodec/mpegaudiodec.c | 13 +++++++------ libavcodec/mpegaudiodec_float.c | 5 ----- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index bc012731b9..ffd369021c 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -266,7 +266,7 @@ static inline int l3_unscale(int value, int exponent) return m; } -static void decode_init_static(AVCodec *codec) +static av_cold void decode_init_static(void) { int i, j, k; int offset; @@ -457,8 +457,14 @@ static void decode_init_static(AVCodec *codec) static av_cold int decode_init(AVCodecContext * avctx) { + static int initialized_tables = 0; MPADecodeContext *s = avctx->priv_data; + if (!initialized_tables) { + decode_init_static(); + initialized_tables = 1; + } + s->avctx = avctx; ff_mpadsp_init(&s->mpadsp); @@ -2110,7 +2116,6 @@ AVCodec ff_mp1_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -2126,7 +2131,6 @@ AVCodec ff_mp2_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -2142,7 +2146,6 @@ AVCodec ff_mp3_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -2158,7 +2161,6 @@ AVCodec ff_mp3adu_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame_adu, #if FF_API_PARSE_FRAME @@ -2174,7 +2176,6 @@ AVCodec ff_mp3on4_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), - .init_static_data = decode_init_static, .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index 4a187369cb..9300de29b9 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -28,7 +28,6 @@ AVCodec ff_mp1float_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -44,7 +43,6 @@ AVCodec ff_mp2float_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -60,7 +58,6 @@ AVCodec ff_mp3float_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame, #if FF_API_PARSE_FRAME @@ -76,7 +73,6 @@ AVCodec ff_mp3adufloat_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), - .init_static_data = decode_init_static, .init = decode_init, .decode = decode_frame_adu, #if FF_API_PARSE_FRAME @@ -92,7 +88,6 @@ AVCodec ff_mp3on4float_decoder = { .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), - .init_static_data = decode_init_static, .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, -- cgit v1.2.3 From 97980db4870675baf553dc190051161ecffa9d77 Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Mon, 28 Nov 2011 02:26:52 +0530 Subject: indeo3: error out if no motion vector is set. This fixes a crash on a corrupt bitstream (bugzilla #93). Signed-off-by: Ronald S. Bultje --- libavcodec/indeo3.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libavcodec') diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 2c7e96b738..e266aeecec 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -756,6 +756,8 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n"); CHECK_CELL + if(!curr_cell.mv_ptr) + return AVERROR_INVALIDDATA; copy_cell(ctx, plane, &curr_cell); return 0; } -- cgit v1.2.3 From 1f948745c3cbe45c4ccd5d8996fc885d826bf3ff Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sat, 26 Nov 2011 13:28:48 +0100 Subject: vc1: use an enum for Frame Coding Mode Document it a little and possibly fix a bug in dxva2_vc1. --- libavcodec/dxva2_vc1.c | 4 ++-- libavcodec/vc1.c | 16 ++++++++-------- libavcodec/vc1.h | 12 +++++++++++- libavcodec/vc1dec.c | 27 ++++++++++++++------------- 4 files changed, 35 insertions(+), 24 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index ba6416b719..f8b74a2b35 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -68,7 +68,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, pp->bPicStructure |= 0x01; if (s->picture_structure & PICT_BOTTOM_FIELD) pp->bPicStructure |= 0x02; - pp->bSecondField = v->interlace && v->fcm != 0x03 && !s->first_field; + pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field; pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I; pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B; pp->bBidirectionalAveragingMode = (1 << 7) | @@ -100,7 +100,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, (s->resync_marker << 4) | (v->rangered << 3) | (s->max_b_frames ); - pp->bPicExtrapolation = (!v->interlace || v->fcm == 0x00) ? 1 : 2; + pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2; pp->bPicDeblocked = ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | (s->loop_filter << 1); pp->bPicDeblockConfined = (v->postprocflag << 7) | diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index cb228e6107..d728f9beb4 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -836,14 +836,14 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) if (v->interlace) { v->fcm = decode012(gb); if (v->fcm) { - if (v->fcm == 2) + if (v->fcm == ILACE_FIELD) v->field_mode = 1; if (!v->warn_interlaced++) av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced frames/fields support is incomplete\n"); } } else { - v->fcm = 0; + v->fcm = PROGRESSIVE; } if (v->field_mode) { @@ -957,7 +957,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) switch (v->s.pict_type) { case AV_PICTURE_TYPE_I: case AV_PICTURE_TYPE_BI: - if (v->fcm == 1) { //interlace frame picture + if (v->fcm == ILACE_FRAME) { //interlace frame picture status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); if (status < 0) return -1; @@ -998,7 +998,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->dmvrange = get_unary(gb, 0, 3); else v->dmvrange = 0; - if (v->fcm == 1) { // interlaced frame picture + if (v->fcm == ILACE_FRAME) { // interlaced frame picture v->fourmvswitch = get_bits1(gb); v->intcomp = get_bits1(gb); if (v->intcomp) { @@ -1038,7 +1038,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) v->tt_index = 1; else v->tt_index = 2; - if (v->fcm != 1) { + if (v->fcm != ILACE_FRAME) { int mvmode; mvmode = get_unary(gb, 1, 4); lowquant = (v->pq > 12) ? 0 : 1; @@ -1073,7 +1073,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); } - if (v->fcm == 0) { // progressive + if (v->fcm == PROGRESSIVE) { // progressive if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { @@ -1095,7 +1095,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) /* Hopefully this is correct for P frames */ v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; - } else if (v->fcm == 1) { // frame interlaced + } else if (v->fcm == ILACE_FRAME) { // frame interlaced v->qs_last = v->s.quarter_sample; v->s.quarter_sample = 1; v->s.mspel = 1; @@ -1135,7 +1135,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) break; case AV_PICTURE_TYPE_B: // TODO: implement interlaced frame B picture decoding - if (v->fcm == 1) + if (v->fcm == ILACE_FRAME) return -1; if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index ac65348352..6096077660 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -161,6 +161,16 @@ enum COTypes { }; //@} +/** + * FCM Frame Coding Mode + * @note some content might be marked interlaced + * but have fcm set to 0 as well (e.g. HD-DVD) + */ +enum FrameCodingMode { + PROGRESSIVE = 0, ///< in the bitstream is reported as 00b + ILACE_FRAME, ///< in the bitstream is reported as 10b + ILACE_FIELD ///< in the bitstream is reported as 11b +}; /** The VC1 Context * @todo Change size wherever another size is more efficient @@ -296,7 +306,7 @@ typedef struct VC1Context{ /** Frame decoding info for Advanced profile */ //@{ - uint8_t fcm; ///< 0->Progressive, 2->Frame-Interlace, 3->Field-Interlace + enum FrameCodingMode fcm; uint8_t numpanscanwin; uint8_t tfcntr; uint8_t rptfrm, tff, rff; diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index c479c08479..b5b8c29bda 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -501,7 +501,8 @@ static void vc1_mc_1mv(VC1Context *v, int dir) uvmy = uvmy - 2 + 4 * v->cur_field_type; } - if (v->fastuvmc && (v->fcm != 1)) { // fastuvmc shall be ignored for interlaced frame picture + // fastuvmc shall be ignored for interlaced frame picture + if (v->fastuvmc && (v->fcm != ILACE_FRAME)) { uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1)); uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1)); } @@ -685,7 +686,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; - int fieldmv = (v->fcm == 1) ? v->blk_mv_type[s->block_index[n]] : 0; + int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; int v_edge_pos = s->v_edge_pos >> v->field_mode; if (!v->field_mode && !v->s.last_picture.f.data[0]) @@ -744,7 +745,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) v->mv_f[1][s->block_index[k] + v->blocks_off] = f; } - if (v->fcm == 1) { // not sure if needed for other types of picture + if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture int qx, qy; int width = s->avctx->coded_width; int height = s->avctx->coded_height >> 1; @@ -761,7 +762,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) my -= 8 * (qy - height - 1); } - if ((v->fcm == 1) && fieldmv) + if ((v->fcm == ILACE_FRAME) && fieldmv) off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8; else off = s->linesize * 4 * (n & 2) + (n & 1) * 8; @@ -779,7 +780,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) src_y = av_clip(src_y, -16, s->mb_height * 16); } else { src_x = av_clip(src_x, -17, s->avctx->coded_width); - if (v->fcm == 1) { + if (v->fcm == ILACE_FRAME) { if (src_y & 1) src_y = av_clip(src_y, -17, s->avctx->coded_height + 1); else @@ -2917,7 +2918,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int k; if (v->s.ac_pred) { - if (!use_pred && v->fcm == 1) { + if (!use_pred && v->fcm == ILACE_FRAME) { zz_table = v->zzi_8x8; } else { if (!dc_pred_dir) // top @@ -2926,7 +2927,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, zz_table = v->zz_8x8[3]; } } else { - if (v->fcm != 1) + if (v->fcm != ILACE_FRAME) zz_table = v->zz_8x8[1]; else zz_table = v->zzi_8x8; @@ -3136,10 +3137,10 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, i += skip; if (i > 63) break; - if (v->fcm == 0) + if (v->fcm == PROGRESSIVE) block[v->zz_8x8[0][i++]] = value; else { - if (use_pred && (v->fcm == 1)) { + if (use_pred && (v->fcm == ILACE_FRAME)) { if (!dc_pred_dir) // top block[v->zz_8x8[2][i++]] = value; else // left @@ -4739,12 +4740,12 @@ static void vc1_decode_p_blocks(VC1Context *v) for (; s->mb_x < s->mb_width; s->mb_x++) { ff_update_block_index(s); - if (v->fcm == 2) + if (v->fcm == ILACE_FIELD) vc1_decode_p_mb_intfi(v); - else if (v->fcm == 1) + else if (v->fcm == ILACE_FRAME) vc1_decode_p_mb_intfr(v); else vc1_decode_p_mb(v); - if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == 0) + if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == PROGRESSIVE) vc1_apply_p_loop_filter(v); if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { // TODO: may need modification to handle slice coding @@ -4811,7 +4812,7 @@ static void vc1_decode_b_blocks(VC1Context *v) for (; s->mb_x < s->mb_width; s->mb_x++) { ff_update_block_index(s); - if (v->fcm == 2) + if (v->fcm == ILACE_FIELD) vc1_decode_b_mb_intfi(v); else vc1_decode_b_mb(v); -- cgit v1.2.3