Commit 1c2a8c7f authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec_flush_buffers()

Originally committed as revision 420 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent eeba58cc
......@@ -5,8 +5,8 @@
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4602
#define LIBAVCODEC_BUILD_STR "4602"
#define LIBAVCODEC_BUILD 4603
#define LIBAVCODEC_BUILD_STR "4603"
enum CodecID {
CODEC_ID_NONE,
......@@ -340,6 +340,8 @@ int avcodec_close(AVCodecContext *avctx);
void avcodec_register_all(void);
void avcodec_flush_buffers(AVCodecContext *avctx);
#ifdef FF_POSTPROCESS
#ifndef MBC
#define MBC 128
......
......@@ -1034,7 +1034,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s)
if(s->low_delay){
put_bits(&s->pb, 1, 1); /* vol control parameters= yes */
put_bits(&s->pb, 2, 1); /* chroma format 422 */
put_bits(&s->pb, 2, 1); /* chroma format YUV 420/YV12 */
put_bits(&s->pb, 1, s->low_delay);
put_bits(&s->pb, 1, 0); /* vbv parameters= no */
}else{
......@@ -2602,7 +2602,7 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
} else {
vo_ver_id = 1;
}
//printf("vo type:%d\n",s->vo_type);
s->aspect_ratio_info= get_bits(&s->gb, 4);
if(s->aspect_ratio_info == EXTENDET_PAR){
skip_bits(&s->gb, 8); //par_width
......
......@@ -135,7 +135,6 @@ static int h263_decode_frame(AVCodecContext *avctx,
} else {
ret = h263_decode_picture_header(s);
}
if(ret==FRAME_SKIPED) return 0;
/* After H263 & mpeg4 header decode we have the height, width,*/
/* and other parameters. So then we could init the picture */
......@@ -154,8 +153,11 @@ static int h263_decode_frame(AVCodecContext *avctx,
return -1;
}
if(ret==FRAME_SKIPED) return 0;
if (ret < 0)
return -1;
/* skip b frames if we dont have reference frames */
if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return 0;
MPV_frame_start(s);
......@@ -222,7 +224,8 @@ static int h263_decode_frame(AVCodecContext *avctx,
}
MPV_decode_mb(s, s->block);
}
if (avctx->draw_horiz_band) {
if ( avctx->draw_horiz_band
&& (s->num_available_buffers>=1 || (!s->has_b_frames)) ) {
UINT8 *src_ptr[3];
int y, h, offset;
y = s->mb_y * 16;
......@@ -279,7 +282,11 @@ static int h263_decode_frame(AVCodecContext *avctx,
/* we substract 1 because it is added on utils.c */
avctx->frame_number = s->picture_number - 1;
/* dont output the last pic after seeking
note we allready added +1 for the current pix in MPV_frame_end(s) */
if(s->num_available_buffers>=2 || (!s->has_b_frames))
*data_size = sizeof(AVPicture);
return buf_size;
}
......
......@@ -629,6 +629,8 @@ void MPV_frame_end(MpegEncContext *s)
s->last_non_b_pict_type= s->pict_type;
s->last_non_b_qscale= s->qscale;
s->last_non_b_mc_mb_var= s->mc_mb_var;
s->num_available_buffers++;
if(s->num_available_buffers>2) s->num_available_buffers= 2;
}
}
......
......@@ -129,6 +129,7 @@ typedef struct MpegEncContext {
UINT8 *aux_picture[3]; /* aux picture (for B frames only) */
UINT8 *aux_picture_base[3]; /* real start of the picture */
UINT8 *current_picture[3]; /* buffer to store the decompressed current picture */
int num_available_buffers; /* is 0 at the start & after seeking, after the first I frame its 1 after next I/P 2 */
int last_dc[3]; /* last DC values for MPEG1 */
INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */
int y_dc_scale, c_dc_scale;
......
......@@ -22,6 +22,7 @@
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
#include "mpegvideo.h"
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
......@@ -479,6 +480,14 @@ PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
#undef PCM_CODEC
}
/* this should be called after seeking and before trying to decode the next frame */
void avcodec_flush_buffers(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
s->num_available_buffers=0;
}
static int encode_init(AVCodecContext *s)
{
return 0;
......
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