1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

export sample_aspect_ratio read by the demuxer in a separate field

that the one read by the decoder.

Originally committed as revision 14932 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Aurelien Jacobs 2008-08-23 23:13:58 +00:00
parent 0cdc6ec941
commit c30a4489b4
4 changed files with 24 additions and 8 deletions

View File

@ -2888,7 +2888,11 @@ static void opt_input_file(const char *filename)
set_context_opts(enc, avctx_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM); set_context_opts(enc, avctx_opts[CODEC_TYPE_VIDEO], AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
frame_height = enc->height; frame_height = enc->height;
frame_width = enc->width; frame_width = enc->width;
frame_aspect_ratio = av_q2d(enc->sample_aspect_ratio) * enc->width / enc->height; if(ic->streams[i]->sample_aspect_ratio.num)
frame_aspect_ratio=av_q2d(ic->streams[i]->sample_aspect_ratio);
else
frame_aspect_ratio=av_q2d(enc->sample_aspect_ratio);
frame_aspect_ratio *= (float) enc->width / enc->height;
frame_pix_fmt = enc->pix_fmt; frame_pix_fmt = enc->pix_fmt;
rfps = ic->streams[i]->r_frame_rate.num; rfps = ic->streams[i]->r_frame_rate.num;
rfps_base = ic->streams[i]->r_frame_rate.den; rfps_base = ic->streams[i]->r_frame_rate.den;
@ -3019,6 +3023,7 @@ static void new_video_stream(AVFormatContext *oc)
if (video_stream_copy) { if (video_stream_copy) {
st->stream_copy = 1; st->stream_copy = 1;
video_enc->codec_type = CODEC_TYPE_VIDEO; video_enc->codec_type = CODEC_TYPE_VIDEO;
st->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
} else { } else {
const char *p; const char *p;
int i; int i;
@ -3056,6 +3061,7 @@ static void new_video_stream(AVFormatContext *oc)
video_enc->height = frame_height + frame_padtop + frame_padbottom; video_enc->height = frame_height + frame_padtop + frame_padbottom;
video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255); video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255);
video_enc->pix_fmt = frame_pix_fmt; video_enc->pix_fmt = frame_pix_fmt;
st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
if(codec && codec->pix_fmts){ if(codec && codec->pix_fmts){
const enum PixelFormat *p= codec->pix_fmts; const enum PixelFormat *p= codec->pix_fmts;

View File

@ -657,14 +657,15 @@ static void video_image_display(VideoState *is)
vp = &is->pictq[is->pictq_rindex]; vp = &is->pictq[is->pictq_rindex];
if (vp->bmp) { if (vp->bmp) {
/* XXX: use variable in the frame */ /* XXX: use variable in the frame */
if (is->video_st->codec->sample_aspect_ratio.num == 0) if (is->video_st->sample_aspect_ratio.num)
aspect_ratio = 0; aspect_ratio = av_q2d(is->video_st->sample_aspect_ratio);
else if (is->video_st->codec->sample_aspect_ratio.num)
aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio);
else else
aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio) aspect_ratio = 0;
* is->video_st->codec->width / is->video_st->codec->height;
if (aspect_ratio <= 0.0) if (aspect_ratio <= 0.0)
aspect_ratio = (float)is->video_st->codec->width / aspect_ratio = 1.0;
(float)is->video_st->codec->height; aspect_ratio *= (float)is->video_st->codec->width / is->video_st->codec->height;
/* if an active format is indicated, then it overrides the /* if an active format is indicated, then it overrides the
mpeg format */ mpeg format */
#if 0 #if 0

View File

@ -22,7 +22,7 @@
#define FFMPEG_AVFORMAT_H #define FFMPEG_AVFORMAT_H
#define LIBAVFORMAT_VERSION_MAJOR 52 #define LIBAVFORMAT_VERSION_MAJOR 52
#define LIBAVFORMAT_VERSION_MINOR 20 #define LIBAVFORMAT_VERSION_MINOR 21
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@ -402,6 +402,13 @@ typedef struct AVStream {
AVProbeData probe_data; AVProbeData probe_data;
#define MAX_REORDER_DELAY 16 #define MAX_REORDER_DELAY 16
int64_t pts_buffer[MAX_REORDER_DELAY+1]; int64_t pts_buffer[MAX_REORDER_DELAY+1];
/**
* sample aspect ratio (0 if unknown)
* - encoding: Set by user.
* - decoding: Set by libavformat.
*/
AVRational sample_aspect_ratio;
} AVStream; } AVStream;
#define AV_PROGRAM_RUNNING 1 #define AV_PROGRAM_RUNNING 1

View File

@ -2331,6 +2331,8 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
for(i=0; i<MAX_REORDER_DELAY+1; i++) for(i=0; i<MAX_REORDER_DELAY+1; i++)
st->pts_buffer[i]= AV_NOPTS_VALUE; st->pts_buffer[i]= AV_NOPTS_VALUE;
st->sample_aspect_ratio = (AVRational){0,1};
s->streams[s->nb_streams++] = st; s->streams[s->nb_streams++] = st;
return st; return st;
} }