Commit 178fcca8 authored by Michael Niedermayer's avatar Michael Niedermayer

1/2 resolution decoding

Originally committed as revision 3507 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent bc133816
...@@ -188,6 +188,8 @@ static int predictor = 0; ...@@ -188,6 +188,8 @@ static int predictor = 0;
static int video_profile = FF_PROFILE_UNKNOWN; static int video_profile = FF_PROFILE_UNKNOWN;
static int video_level = FF_LEVEL_UNKNOWN; static int video_level = FF_LEVEL_UNKNOWN;
static int nsse_weight = 8; static int nsse_weight = 8;
static int subpel_quality= 8;
static int lowres= 0;
extern int loop_input; /* currently a hack */ extern int loop_input; /* currently a hack */
static int gop_size = 12; static int gop_size = 12;
...@@ -3148,6 +3150,8 @@ static void opt_output_file(const char *filename) ...@@ -3148,6 +3150,8 @@ static void opt_output_file(const char *filename)
video_enc->profile= video_profile; video_enc->profile= video_profile;
video_enc->level= video_level; video_enc->level= video_level;
video_enc->nsse_weight= nsse_weight; video_enc->nsse_weight= nsse_weight;
video_enc->me_subpel_quality= subpel_quality;
video_enc->lowres= lowres;
if(packet_size){ if(packet_size){
video_enc->rtp_mode= 1; video_enc->rtp_mode= 1;
...@@ -3840,6 +3844,8 @@ const OptionDef options[] = { ...@@ -3840,6 +3844,8 @@ const OptionDef options[] = {
{ "vprofile", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_profile}, "profile", "" }, { "vprofile", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_profile}, "profile", "" },
{ "vlevel", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_level}, "level", "" }, { "vlevel", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_level}, "level", "" },
{ "nssew", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&nsse_weight}, "weight", "" }, { "nssew", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&nsse_weight}, "weight", "" },
{ "subq", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&subpel_quality}, "", "" },
{ "lowres", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&lowres}, "", "" },
/* audio options */ /* audio options */
{ "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", }, { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", },
......
...@@ -171,6 +171,8 @@ static int step = 0; ...@@ -171,6 +171,8 @@ static int step = 0;
static int thread_count = 1; static int thread_count = 1;
static int workaround_bugs = 1; static int workaround_bugs = 1;
static int fast = 0; static int fast = 0;
static int lowres = 0;
static int idct = FF_IDCT_AUTO;
/* current context */ /* current context */
static int is_full_screen; static int is_full_screen;
...@@ -1173,6 +1175,8 @@ static int stream_component_open(VideoState *is, int stream_index) ...@@ -1173,6 +1175,8 @@ static int stream_component_open(VideoState *is, int stream_index)
enc->debug_mv = debug_mv; enc->debug_mv = debug_mv;
enc->debug = debug; enc->debug = debug;
enc->workaround_bugs = workaround_bugs; enc->workaround_bugs = workaround_bugs;
enc->lowres = lowres;
enc->idct_algo= idct;
if(fast) enc->flags2 |= CODEC_FLAG2_FAST; if(fast) enc->flags2 |= CODEC_FLAG2_FAST;
if (!codec || if (!codec ||
avcodec_open(enc, codec) < 0) avcodec_open(enc, codec) < 0)
...@@ -1832,6 +1836,8 @@ const OptionDef options[] = { ...@@ -1832,6 +1836,8 @@ const OptionDef options[] = {
{ "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" }, { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
{ "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" }, { "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
{ "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" }, { "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
{ "lowres", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&lowres}, "", "" },
{ "idct", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&idct}, "set idct algo", "algo" },
#ifdef CONFIG_NETWORK #ifdef CONFIG_NETWORK
{ "rtp_tcp", OPT_EXPERT, {(void*)&opt_rtp_tcp}, "force RTP/TCP protocol usage", "" }, { "rtp_tcp", OPT_EXPERT, {(void*)&opt_rtp_tcp}, "force RTP/TCP protocol usage", "" },
#endif #endif
......
...@@ -17,7 +17,7 @@ extern "C" { ...@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1" #define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 4721 #define LIBAVCODEC_BUILD 4722
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION #define LIBAVCODEC_VERSION FFMPEG_VERSION
...@@ -1111,6 +1111,7 @@ typedef struct AVCodecContext { ...@@ -1111,6 +1111,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_ALTIVEC 8 #define FF_IDCT_ALTIVEC 8
#define FF_IDCT_SH4 9 #define FF_IDCT_SH4 9
#define FF_IDCT_SIMPLEARM 10 #define FF_IDCT_SIMPLEARM 10
#define FF_IDCT_INT4 11
/** /**
* slice count. * slice count.
...@@ -1656,6 +1657,13 @@ typedef struct AVCodecContext { ...@@ -1656,6 +1657,13 @@ typedef struct AVCodecContext {
*/ */
int level; int level;
#define FF_LEVEL_UNKNOWN -99 #define FF_LEVEL_UNKNOWN -99
/**
* low resolution decoding. 1-> 1/2 size, 2->1/4 size
* - encoding: unused
* - decoding: set by user
*/
int lowres;
} AVCodecContext; } AVCodecContext;
......
...@@ -446,6 +446,24 @@ static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, ...@@ -446,6 +446,24 @@ static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
} }
} }
static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<4;i++) {
pixels[0] = cm[block[0]];
pixels[1] = cm[block[1]];
pixels[2] = cm[block[2]];
pixels[3] = cm[block[3]];
pixels += line_size;
block += 8;
}
}
static void put_signed_pixels_clamped_c(const DCTELEM *block, static void put_signed_pixels_clamped_c(const DCTELEM *block,
uint8_t *restrict pixels, uint8_t *restrict pixels,
int line_size) int line_size)
...@@ -487,6 +505,23 @@ static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, ...@@ -487,6 +505,23 @@ static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
block += 8; block += 8;
} }
} }
static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* read the pixels */
for(i=0;i<4;i++) {
pixels[0] = cm[pixels[0] + block[0]];
pixels[1] = cm[pixels[1] + block[1]];
pixels[2] = cm[pixels[2] + block[2]];
pixels[3] = cm[pixels[3] + block[3]];
pixels += line_size;
block += 8;
}
}
#if 0 #if 0
#define PIXOP2(OPNAME, OP) \ #define PIXOP2(OPNAME, OP) \
...@@ -3294,6 +3329,17 @@ static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block) ...@@ -3294,6 +3329,17 @@ static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
add_pixels_clamped_c(block, dest, line_size); add_pixels_clamped_c(block, dest, line_size);
} }
static void ff_jref_idct4_put(uint8_t *dest, int line_size, DCTELEM *block)
{
j_rev_dct4 (block);
put_pixels_clamped4_c(block, dest, line_size);
}
static void ff_jref_idct4_add(uint8_t *dest, int line_size, DCTELEM *block)
{
j_rev_dct4 (block);
add_pixels_clamped4_c(block, dest, line_size);
}
/* init static data */ /* init static data */
void dsputil_static_init(void) void dsputil_static_init(void)
{ {
...@@ -3332,6 +3378,12 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) ...@@ -3332,6 +3378,12 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
} }
#endif //CONFIG_ENCODERS #endif //CONFIG_ENCODERS
if(avctx->lowres==1){
c->idct_put= ff_jref_idct4_put;
c->idct_add= ff_jref_idct4_add;
c->idct = j_rev_dct4;
c->idct_permutation_type= FF_NO_IDCT_PERM;
}else{
if(avctx->idct_algo==FF_IDCT_INT){ if(avctx->idct_algo==FF_IDCT_INT){
c->idct_put= ff_jref_idct_put; c->idct_put= ff_jref_idct_put;
c->idct_add= ff_jref_idct_add; c->idct_add= ff_jref_idct_add;
...@@ -3343,6 +3395,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) ...@@ -3343,6 +3395,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->idct = simple_idct; c->idct = simple_idct;
c->idct_permutation_type= FF_NO_IDCT_PERM; c->idct_permutation_type= FF_NO_IDCT_PERM;
} }
}
/* VP3 DSP support */ /* VP3 DSP support */
c->vp3_dsp_init = vp3_dsp_init_c; c->vp3_dsp_init = vp3_dsp_init_c;
......
...@@ -42,6 +42,7 @@ void ff_jpeg_fdct_islow (DCTELEM *data); ...@@ -42,6 +42,7 @@ void ff_jpeg_fdct_islow (DCTELEM *data);
void ff_fdct248_islow (DCTELEM *data); void ff_fdct248_islow (DCTELEM *data);
void j_rev_dct (DCTELEM *data); void j_rev_dct (DCTELEM *data);
void j_rev_dct4 (DCTELEM *data);
void ff_fdct_mmx(DCTELEM *block); void ff_fdct_mmx(DCTELEM *block);
void ff_fdct_mmx2(DCTELEM *block); void ff_fdct_mmx2(DCTELEM *block);
......
...@@ -2984,7 +2984,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) ...@@ -2984,7 +2984,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
} }
} }
#endif //CONFIG_ENCODERS #endif //CONFIG_ENCODERS
if(avctx->lowres==0){
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx; c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx; c->idct_add= ff_simple_idct_add_mmx;
...@@ -3002,6 +3002,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) ...@@ -3002,6 +3002,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
} }
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
} }
}
/* VP3 optimized DSP functions */ /* VP3 optimized DSP functions */
if (mm_flags & MM_SSE2) { if (mm_flags & MM_SSE2) {
......
This diff is collapsed.
...@@ -2409,6 +2409,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, ...@@ -2409,6 +2409,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
AVCodecContext *avctx= s->avctx; AVCodecContext *avctx= s->avctx;
int ret; int ret;
const int field_pic= s->picture_structure != PICT_FRAME; const int field_pic= s->picture_structure != PICT_FRAME;
const int lowres= s->avctx->lowres;
s->resync_mb_x= s->resync_mb_x=
s->resync_mb_y= -1; s->resync_mb_y= -1;
...@@ -2518,9 +2519,9 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, ...@@ -2518,9 +2519,9 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
} }
} }
s->dest[0] += 16; s->dest[0] += 16 >> lowres;
s->dest[1] += 16 >> s->chroma_x_shift; s->dest[1] += 16 >> (s->chroma_x_shift + lowres);
s->dest[2] += 16 >> s->chroma_x_shift; s->dest[2] += 16 >> (s->chroma_x_shift + lowres);
MPV_decode_mb(s, s->block); MPV_decode_mb(s, s->block);
......
This diff is collapsed.
...@@ -773,15 +773,17 @@ extern enum PixelFormat ff_yuv420p_list[2]; ...@@ -773,15 +773,17 @@ extern enum PixelFormat ff_yuv420p_list[2];
void ff_init_block_index(MpegEncContext *s); void ff_init_block_index(MpegEncContext *s);
static inline void ff_update_block_index(MpegEncContext *s){ static inline void ff_update_block_index(MpegEncContext *s){
const int block_size= 8>>s->avctx->lowres;
s->block_index[0]+=2; s->block_index[0]+=2;
s->block_index[1]+=2; s->block_index[1]+=2;
s->block_index[2]+=2; s->block_index[2]+=2;
s->block_index[3]+=2; s->block_index[3]+=2;
s->block_index[4]++; s->block_index[4]++;
s->block_index[5]++; s->block_index[5]++;
s->dest[0]+= 16; s->dest[0]+= 2*block_size;
s->dest[1]+= 8; s->dest[1]+= block_size;
s->dest[2]+= 8; s->dest[2]+= block_size;
} }
static inline int get_bits_diff(MpegEncContext *s){ static inline int get_bits_diff(MpegEncContext *s){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment