diff options
Diffstat (limited to 'src/libffmpeg/libavcodec/mpegvideo.c')
-rw-r--r-- | src/libffmpeg/libavcodec/mpegvideo.c | 72 |
1 files changed, 7 insertions, 65 deletions
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c index bef088a41..41ee62435 100644 --- a/src/libffmpeg/libavcodec/mpegvideo.c +++ b/src/libffmpeg/libavcodec/mpegvideo.c @@ -605,6 +605,11 @@ int MPV_common_init(MpegEncContext *s) { int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y; + if(s->avctx->thread_count > MAX_THREADS || (16*s->avctx->thread_count > s->height && s->height)){ + av_log(s->avctx, AV_LOG_ERROR, "too many threads\n"); + return -1; + } + dsputil_init(&s->dsp, s->avctx); DCT_common_init(s); @@ -850,7 +855,6 @@ void MPV_common_end(MpegEncContext *s) } } av_freep(&s->picture); - avcodec_default_free_buffers(s->avctx); s->context_initialized = 0; s->last_picture_ptr= s->next_picture_ptr= @@ -893,6 +897,7 @@ int MPV_encode_init(AVCodecContext *avctx) s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; s->mpeg_quant= avctx->mpeg_quant; s->rtp_mode= !!avctx->rtp_payload_size; + s->intra_dc_precision= avctx->intra_dc_precision; if (s->gop_size <= 1) { s->intra_only = 1; @@ -998,11 +1003,6 @@ int MPV_encode_init(AVCodecContext *avctx) return -1; } - if(s->avctx->thread_count > MAX_THREADS || 16*s->avctx->thread_count > s->height){ - av_log(avctx, AV_LOG_ERROR, "too many threads\n"); - return -1; - } - if(s->avctx->thread_count > 1) s->rtp_mode= 1; @@ -3727,64 +3727,6 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) #endif //CONFIG_ENCODERS -/** - * combines the (truncated) bitstream to a complete frame - * @returns -1 if no complete frame could be created - */ -int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size){ - ParseContext *pc= &s->parse_context; - -#if 0 - if(pc->overread){ - printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); - printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); - } -#endif - - /* copy overreaded byes from last frame into buffer */ - for(; pc->overread>0; pc->overread--){ - pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; - } - - pc->last_index= pc->index; - - /* copy into buffer end return */ - if(next == END_NOT_FOUND){ - pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - memcpy(&pc->buffer[pc->index], *buf, *buf_size); - pc->index += *buf_size; - return -1; - } - - *buf_size= - pc->overread_index= pc->index + next; - - /* append to buffer */ - if(pc->index){ - pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); - pc->index = 0; - *buf= pc->buffer; - } - - /* store overread bytes */ - for(;next < 0; next++){ - pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next]; - pc->overread++; - } - -#if 0 - if(pc->overread){ - printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index); - printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]); - } -#endif - - return 0; -} - void ff_mpeg_flush(AVCodecContext *avctx){ int i; MpegEncContext *s = avctx->priv_data; @@ -4099,7 +4041,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ for(i=0; i<3; i++){ /* init last dc values */ /* note: quant matrix value (8) is implied here */ - s->last_dc[i] = 128; + s->last_dc[i] = 128 << s->intra_dc_precision; s->current_picture_ptr->error[i] = 0; } |