mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-23 23:40:15 +01:00
avcodec_flush_buffers()
Originally committed as revision 420 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT 0x000406
|
#define LIBAVCODEC_VERSION_INT 0x000406
|
||||||
#define LIBAVCODEC_VERSION "0.4.6"
|
#define LIBAVCODEC_VERSION "0.4.6"
|
||||||
#define LIBAVCODEC_BUILD 4602
|
#define LIBAVCODEC_BUILD 4603
|
||||||
#define LIBAVCODEC_BUILD_STR "4602"
|
#define LIBAVCODEC_BUILD_STR "4603"
|
||||||
|
|
||||||
enum CodecID {
|
enum CodecID {
|
||||||
CODEC_ID_NONE,
|
CODEC_ID_NONE,
|
||||||
@@ -340,6 +340,8 @@ int avcodec_close(AVCodecContext *avctx);
|
|||||||
|
|
||||||
void avcodec_register_all(void);
|
void avcodec_register_all(void);
|
||||||
|
|
||||||
|
void avcodec_flush_buffers(AVCodecContext *avctx);
|
||||||
|
|
||||||
#ifdef FF_POSTPROCESS
|
#ifdef FF_POSTPROCESS
|
||||||
#ifndef MBC
|
#ifndef MBC
|
||||||
#define MBC 128
|
#define MBC 128
|
||||||
|
|||||||
@@ -1034,7 +1034,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s)
|
|||||||
|
|
||||||
if(s->low_delay){
|
if(s->low_delay){
|
||||||
put_bits(&s->pb, 1, 1); /* vol control parameters= yes */
|
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, s->low_delay);
|
||||||
put_bits(&s->pb, 1, 0); /* vbv parameters= no */
|
put_bits(&s->pb, 1, 0); /* vbv parameters= no */
|
||||||
}else{
|
}else{
|
||||||
@@ -2602,7 +2602,7 @@ int mpeg4_decode_picture_header(MpegEncContext * s)
|
|||||||
} else {
|
} else {
|
||||||
vo_ver_id = 1;
|
vo_ver_id = 1;
|
||||||
}
|
}
|
||||||
|
//printf("vo type:%d\n",s->vo_type);
|
||||||
s->aspect_ratio_info= get_bits(&s->gb, 4);
|
s->aspect_ratio_info= get_bits(&s->gb, 4);
|
||||||
if(s->aspect_ratio_info == EXTENDET_PAR){
|
if(s->aspect_ratio_info == EXTENDET_PAR){
|
||||||
skip_bits(&s->gb, 8); //par_width
|
skip_bits(&s->gb, 8); //par_width
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ static int h263_decode_frame(AVCodecContext *avctx,
|
|||||||
} else {
|
} else {
|
||||||
ret = h263_decode_picture_header(s);
|
ret = h263_decode_picture_header(s);
|
||||||
}
|
}
|
||||||
if(ret==FRAME_SKIPED) return 0;
|
|
||||||
|
|
||||||
/* After H263 & mpeg4 header decode we have the height, width,*/
|
/* After H263 & mpeg4 header decode we have the height, width,*/
|
||||||
/* and other parameters. So then we could init the picture */
|
/* and other parameters. So then we could init the picture */
|
||||||
@@ -154,9 +153,12 @@ static int h263_decode_frame(AVCodecContext *avctx,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ret==FRAME_SKIPED) return 0;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
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);
|
MPV_frame_start(s);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -222,7 +224,8 @@ static int h263_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
MPV_decode_mb(s, s->block);
|
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];
|
UINT8 *src_ptr[3];
|
||||||
int y, h, offset;
|
int y, h, offset;
|
||||||
y = s->mb_y * 16;
|
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 */
|
/* we substract 1 because it is added on utils.c */
|
||||||
avctx->frame_number = s->picture_number - 1;
|
avctx->frame_number = s->picture_number - 1;
|
||||||
|
|
||||||
*data_size = sizeof(AVPicture);
|
/* 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;
|
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_pict_type= s->pict_type;
|
||||||
s->last_non_b_qscale= s->qscale;
|
s->last_non_b_qscale= s->qscale;
|
||||||
s->last_non_b_mc_mb_var= s->mc_mb_var;
|
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[3]; /* aux picture (for B frames only) */
|
||||||
UINT8 *aux_picture_base[3]; /* real start of the picture */
|
UINT8 *aux_picture_base[3]; /* real start of the picture */
|
||||||
UINT8 *current_picture[3]; /* buffer to store the decompressed current 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 */
|
int last_dc[3]; /* last DC values for MPEG1 */
|
||||||
INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */
|
INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */
|
||||||
int y_dc_scale, c_dc_scale;
|
int y_dc_scale, c_dc_scale;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "mpegvideo.h"
|
||||||
#ifdef HAVE_MALLOC_H
|
#ifdef HAVE_MALLOC_H
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#else
|
#else
|
||||||
@@ -479,6 +480,14 @@ PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
|
|||||||
#undef PCM_CODEC
|
#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)
|
static int encode_init(AVCodecContext *s)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user