Revision d375c104 libavcodec/mpeg12.c
libavcodec/mpeg12.c | ||
---|---|---|
37 | 37 |
#include "bytestream.h" |
38 | 38 |
#include "vdpau_internal.h" |
39 | 39 |
#include "xvmc_internal.h" |
40 |
#include "thread.h" |
|
40 | 41 |
|
41 | 42 |
//#undef NDEBUG |
42 | 43 |
//#include <assert.h> |
... | ... | |
1179 | 1180 |
return 0; |
1180 | 1181 |
} |
1181 | 1182 |
|
1183 |
static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from) |
|
1184 |
{ |
|
1185 |
Mpeg1Context *ctx = avctx->priv_data, *ctx_from = avctx_from->priv_data; |
|
1186 |
MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx; |
|
1187 |
int err; |
|
1188 |
|
|
1189 |
if(avctx == avctx_from || !ctx_from->mpeg_enc_ctx_allocated || !s1->context_initialized) |
|
1190 |
return 0; |
|
1191 |
|
|
1192 |
err = ff_mpeg_update_thread_context(avctx, avctx_from); |
|
1193 |
if(err) return err; |
|
1194 |
|
|
1195 |
if(!ctx->mpeg_enc_ctx_allocated) |
|
1196 |
memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext)); |
|
1197 |
|
|
1198 |
if(!(s->pict_type == FF_B_TYPE || s->low_delay)) |
|
1199 |
s->picture_number++; |
|
1200 |
|
|
1201 |
return 0; |
|
1202 |
} |
|
1203 |
|
|
1182 | 1204 |
static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, |
1183 | 1205 |
const uint8_t *new_perm){ |
1184 | 1206 |
uint16_t temp_matrix[64]; |
... | ... | |
1595 | 1617 |
} |
1596 | 1618 |
|
1597 | 1619 |
*s->current_picture_ptr->pan_scan= s1->pan_scan; |
1620 |
|
|
1621 |
if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) |
|
1622 |
ff_thread_finish_setup(avctx); |
|
1598 | 1623 |
}else{ //second field |
1599 | 1624 |
int i; |
1600 | 1625 |
|
... | ... | |
1769 | 1794 |
const int mb_size= 16>>s->avctx->lowres; |
1770 | 1795 |
|
1771 | 1796 |
ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); |
1797 |
MPV_report_decode_progress(s); |
|
1772 | 1798 |
|
1773 | 1799 |
s->mb_x = 0; |
1774 | 1800 |
s->mb_y += 1<<field_pic; |
... | ... | |
1924 | 1950 |
*pict= *(AVFrame*)s->current_picture_ptr; |
1925 | 1951 |
ff_print_debug_info(s, pict); |
1926 | 1952 |
} else { |
1927 |
s->picture_number++; |
|
1953 |
if (avctx->active_thread_type&FF_THREAD_FRAME) |
|
1954 |
s->picture_number++; |
|
1928 | 1955 |
/* latency of 1 frame for I- and P-frames */ |
1929 | 1956 |
/* XXX: use another variable than picture_number */ |
1930 | 1957 |
if (s->last_picture_ptr != NULL) { |
... | ... | |
2260 | 2287 |
buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code); |
2261 | 2288 |
if (start_code > 0x1ff){ |
2262 | 2289 |
if(s2->pict_type != FF_B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){ |
2263 |
if(avctx->thread_count > 1){
|
|
2290 |
if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
|
|
2264 | 2291 |
int i; |
2265 | 2292 |
|
2266 | 2293 |
avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*)); |
... | ... | |
2422 | 2449 |
break; |
2423 | 2450 |
} |
2424 | 2451 |
|
2425 |
if(avctx->thread_count > 1){
|
|
2452 |
if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
|
|
2426 | 2453 |
int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count; |
2427 | 2454 |
if(threshold <= mb_y){ |
2428 | 2455 |
MpegEncContext *thread_context= s2->thread_context[s->slice_count]; |
... | ... | |
2496 | 2523 |
.flush= flush, |
2497 | 2524 |
.max_lowres= 3, |
2498 | 2525 |
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), |
2526 |
.update_thread_context= ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context) |
|
2499 | 2527 |
}; |
2500 | 2528 |
|
2501 | 2529 |
AVCodec ff_mpeg2video_decoder = { |
... | ... | |
2532 | 2560 |
|
2533 | 2561 |
#if CONFIG_MPEG_XVMC_DECODER |
2534 | 2562 |
static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){ |
2535 |
if( avctx->thread_count > 1)
|
|
2563 |
if( avctx->active_thread_type & FF_THREAD_SLICE )
|
|
2536 | 2564 |
return -1; |
2537 | 2565 |
if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) ) |
2538 | 2566 |
return -1; |
Also available in: Unified diff