summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-02-25 17:35:52 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-02-25 17:35:52 +0000
commit9740beffc65d08ba454ce4c1d904b6d9388a6544 (patch)
treeaac8e8724add20e3f08ab24c0bf7d15f847dd56f /libavcodec
parent8ac5c1b2d343ef6c1c759d3fb5a32de984ff9ab5 (diff)
use AVFrame.pts=AV_NOPTS_VALUE instead of AVFrame.pts=0
move AV_NOPTS_VALUE & AV_TIME_BASE from avformat.h -> avcodec.h related fixes Originally committed as revision 2814 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h9
-rw-r--r--libavcodec/h263.c17
-rw-r--r--libavcodec/mpegvideo.c8
-rw-r--r--libavcodec/utils.c16
4 files changed, 32 insertions, 18 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0fc295bf12..3d66f56726 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000408
#define FFMPEG_VERSION "0.4.8"
-#define LIBAVCODEC_BUILD 4703
+#define LIBAVCODEC_BUILD 4704
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
@@ -26,6 +26,9 @@ extern "C" {
#define AV_TOSTRING(s) #s
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
+#define AV_NOPTS_VALUE INT64_MIN
+#define AV_TIME_BASE 1000000
+
enum CodecID {
CODEC_ID_NONE,
CODEC_ID_MPEG1VIDEO,
@@ -372,8 +375,8 @@ typedef struct AVPanScan{
int pict_type;\
\
/**\
- * presentation timestamp in micro seconds (time when frame should be shown to user)\
- * if 0 then the frame_rate will be used as reference\
+ * presentation timestamp in AV_TIME_BASE (=micro seconds currently) (time when frame should be shown to user)\
+ * if AV_NOPTS_VALUE then the frame_rate will be used as reference\
* - encoding: MUST be set by user\
* - decoding: set by lavc\
*/\
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 2318c07774..3df42aabe9 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -2156,8 +2156,8 @@ void ff_mpeg4_stuffing(PutBitContext * pbc)
void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
int time_div, time_mod;
- assert(s->current_picture_ptr->pts);
- s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + 500*1000)/(1000*1000);
+ assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
+ s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + AV_TIME_BASE/2)/AV_TIME_BASE;
time_div= s->time/s->time_increment_resolution;
time_mod= s->time%s->time_increment_resolution;
@@ -2179,11 +2179,10 @@ static void mpeg4_encode_gop_header(MpegEncContext * s){
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, GOP_STARTCODE);
- if(s->current_picture_ptr->pts && s->reordered_input_picture[1]){
- time= FFMIN(s->reordered_input_picture[1]->pts, s->current_picture_ptr->pts);
- time= (time*s->time_increment_resolution + 500*1000)/(1000*1000);
- }else
- time= av_rescale(s->current_picture_ptr->coded_picture_number*(int64_t)s->avctx->frame_rate_base, s->time_increment_resolution, s->avctx->frame_rate);
+ time= s->current_picture_ptr->pts;
+ if(s->reordered_input_picture[1])
+ time= FFMIN(time, s->reordered_input_picture[1]->pts);
+ time= (time*s->time_increment_resolution + AV_TIME_BASE/2)/AV_TIME_BASE;
seconds= time/s->time_increment_resolution;
minutes= seconds/60; seconds %= 60;
@@ -5709,9 +5708,9 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
- ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
}
- s->current_picture_ptr->pts= s->time*1000LL*1000LL / s->time_increment_resolution;
+ s->current_picture_ptr->pts= s->time*(int64_t)AV_TIME_BASE / s->time_increment_resolution;
if(s->avctx->debug&FF_DEBUG_PTS)
- av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(1000.0*1000.0));
+ av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(float)AV_TIME_BASE);
check_marker(gb, "before vop_coded");
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index a5048e3968..3ce01c43aa 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1850,14 +1850,14 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
copy_picture_attributes(pic, pic_arg);
pic->display_picture_number= s->input_picture_number++;
- if(pic->pts){
+ if(pic->pts != AV_NOPTS_VALUE){
s->user_specified_pts= pic->pts;
}else{
if(s->user_specified_pts){
- pic->pts= s->user_specified_pts + 1000ULL*1000ULL*s->avctx->frame_rate_base / s->avctx->frame_rate;
- av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=0 trying to guess (%Ld)\n", pic->pts);
+ pic->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate;
+ av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic->pts);
}else{
- pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, 1000*1000, s->avctx->frame_rate);
+ pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate);
}
}
}
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index eb4b19eedc..7227e4f507 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -339,6 +339,8 @@ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum Pixel
}
void avcodec_get_context_defaults(AVCodecContext *s){
+ memset(s, 0, sizeof(AVCodecContext));
+
s->bit_rate= 800*1000;
s->bit_rate_tolerance= s->bit_rate*10;
s->qmin= 2;
@@ -381,7 +383,7 @@ void avcodec_get_context_defaults(AVCodecContext *s){
* this can be deallocated by simply calling free()
*/
AVCodecContext *avcodec_alloc_context(void){
- AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext));
+ AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
if(avctx==NULL) return NULL;
@@ -390,12 +392,22 @@ AVCodecContext *avcodec_alloc_context(void){
return avctx;
}
+void avcodec_get_frame_defaults(AVFrame *pic){
+ memset(pic, 0, sizeof(AVFrame));
+
+ pic->pts= AV_NOPTS_VALUE;
+}
+
/**
* allocates a AVPFrame and set it to defaults.
* this can be deallocated by simply calling free()
*/
AVFrame *avcodec_alloc_frame(void){
- AVFrame *pic= av_mallocz(sizeof(AVFrame));
+ AVFrame *pic= av_malloc(sizeof(AVFrame));
+
+ if(pic==NULL) return NULL;
+
+ avcodec_get_frame_defaults(pic);
return pic;
}