avcodec/mpegvideo: support disabling motion compensation
This allows analyzing videos without having prior and current frames mixed Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
1ccd1a3860
commit
c60b266eac
@ -2587,6 +2587,7 @@ typedef struct AVCodecContext {
|
||||
#endif
|
||||
#define FF_DEBUG_BUFFERS 0x00008000
|
||||
#define FF_DEBUG_THREADS 0x00010000
|
||||
#define FF_DEBUG_NOMC 0x01000000
|
||||
|
||||
#if FF_API_DEBUG_MV
|
||||
/**
|
||||
|
@ -340,6 +340,18 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
|
||||
ff_MPV_decode_mb(s, s->block);
|
||||
}
|
||||
|
||||
static void gray16(uint8_t *dst, uint8_t *src, int linesize, int h)
|
||||
{
|
||||
while(h--)
|
||||
memset(dst + h*linesize, 128, 16);
|
||||
}
|
||||
|
||||
static void gray8(uint8_t *dst, uint8_t *src, int linesize, int h)
|
||||
{
|
||||
while(h--)
|
||||
memset(dst + h*linesize, 128, 8);
|
||||
}
|
||||
|
||||
/* init common dct for both encoder and decoder */
|
||||
av_cold int ff_dct_common_init(MpegEncContext *s)
|
||||
{
|
||||
@ -348,6 +360,19 @@ av_cold int ff_dct_common_init(MpegEncContext *s)
|
||||
ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
|
||||
ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
|
||||
|
||||
if (s->avctx->debug & FF_DEBUG_NOMC) {
|
||||
int i;
|
||||
for (i=0; i<4; i++) {
|
||||
s->hdsp.avg_pixels_tab[0][i] = gray16;
|
||||
s->hdsp.put_pixels_tab[0][i] = gray16;
|
||||
s->hdsp.put_no_rnd_pixels_tab[0][i] = gray16;
|
||||
|
||||
s->hdsp.avg_pixels_tab[1][i] = gray8;
|
||||
s->hdsp.put_pixels_tab[1][i] = gray8;
|
||||
s->hdsp.put_no_rnd_pixels_tab[1][i] = gray8;
|
||||
}
|
||||
}
|
||||
|
||||
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;
|
||||
s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c;
|
||||
s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;
|
||||
@ -1656,6 +1681,22 @@ int ff_find_unused_picture(MpegEncContext *s, int shared)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void gray_frame(AVFrame *frame)
|
||||
{
|
||||
int i, h_chroma_shift, v_chroma_shift;
|
||||
|
||||
av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift);
|
||||
|
||||
for(i=0; i<frame->height; i++)
|
||||
memset(frame->data[0] + frame->linesize[0]*i, 0x80, frame->width);
|
||||
for(i=0; i<FF_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) {
|
||||
memset(frame->data[1] + frame->linesize[1]*i,
|
||||
0x80, FF_CEIL_RSHIFT(frame->width, h_chroma_shift));
|
||||
memset(frame->data[2] + frame->linesize[2]*i,
|
||||
0x80, FF_CEIL_RSHIFT(frame->width, h_chroma_shift));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generic function called after decoding
|
||||
* the header and before a frame is decoded.
|
||||
@ -1882,6 +1923,10 @@ int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
|
||||
}
|
||||
|
||||
if (s->avctx->debug & FF_DEBUG_NOMC) {
|
||||
gray_frame(s->current_picture_ptr->f);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -248,6 +248,7 @@ static const AVOption avcodec_options[] = {
|
||||
{"vis_mb_type", "visualize block types", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"},
|
||||
{"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"},
|
||||
{"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|A|D, "debug"},
|
||||
{"nomc", "skip motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_NOMC }, INT_MIN, INT_MAX, V|A|D, "debug"},
|
||||
{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|D, "debug_mv"},
|
||||
{"pf", "forward predicted MVs of P-frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MV_P_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"},
|
||||
{"bf", "forward predicted MVs of B-frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MV_B_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user