History

lavc: add a sample_aspect_ratio field to AVFrame

The sample aspect ratio is a per-frame property, so it makes sense to define it in AVFrame rather than in the codec/stream context. Simplify application-level sample aspect ratio information extraction, and allow further simplifications.

Stefano Sabatini committed 15 years ago

Commit 77e9dee1 parent 1ba572710 files · +28 −15Browse files

Showing the changes to libavfilter (3 of 10 files). Show all

Unified · Split

3 files
  1. libavfilter/vsrc_buffer.c +5 −5
  2. libavfilter/vsrc_buffer.h +2 −2
  3. libavfilter/vsrc_movie.c +2 −2
libavfilter/vsrc_buffer.c+5−5
@@ -39,7 +39,7 @@ typedef struct { · 38 unmodified lines
39} BufferSourceContext;39} BufferSourceContext;
40 40
41int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,41int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
42 int64_t pts, AVRational pixel_aspect, int width,42 int64_t pts, int width,
43 int height, enum PixelFormat pix_fmt,43 int height, enum PixelFormat pix_fmt,
44 const char *sws_param)44 const char *sws_param)
45{45{
@@ -104,20 +104,20 @@ int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame, · 58 unmodified lines
104 c->frame.top_field_first = frame->top_field_first;104 c->frame.top_field_first = frame->top_field_first;
105 c->frame.key_frame = frame->key_frame;105 c->frame.key_frame = frame->key_frame;
106 c->frame.pict_type = frame->pict_type;106 c->frame.pict_type = frame->pict_type;
107 c->frame.sample_aspect_ratio = frame->sample_aspect_ratio;
107 c->pts = pts;108 c->pts = pts;
108 c->pixel_aspect = pixel_aspect;
109 c->has_frame = 1;109 c->has_frame = 1;
110 110
111 return 0;111 return 0;
112}112}
113 113
114int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,114int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
115 int64_t pts, AVRational pixel_aspect)115 int64_t pts)
116{116{
117 BufferSourceContext *c = buffer_filter->priv;117 BufferSourceContext *c = buffer_filter->priv;
118 118
119 return av_vsrc_buffer_add_frame2(buffer_filter, frame,119 return av_vsrc_buffer_add_frame2(buffer_filter, frame,
120 pts, pixel_aspect, c->w,120 pts, c->w,
121 c->h, c->pix_fmt, "");121 c->h, c->pix_fmt, "");
122}122}
123 123
@@ -190,7 +190,7 @@ static int request_frame(AVFilterLink *link) · 66 unmodified lines
190 picref->format, link->w, link->h);190 picref->format, link->w, link->h);
191 191
192 picref->pts = c->pts;192 picref->pts = c->pts;
193 picref->video->pixel_aspect = c->pixel_aspect;193 picref->video->pixel_aspect = c->frame.sample_aspect_ratio;
194 picref->video->interlaced = c->frame.interlaced_frame;194 picref->video->interlaced = c->frame.interlaced_frame;
195 picref->video->top_field_first = c->frame.top_field_first;195 picref->video->top_field_first = c->frame.top_field_first;
196 picref->video->key_frame = c->frame.key_frame;196 picref->video->key_frame = c->frame.key_frame;
libavfilter/vsrc_buffer.h+2−2
@@ -31,10 +31,10 @@ · 30 unmodified lines
31#include "avfilter.h"31#include "avfilter.h"
32 32
33int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,33int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
34 int64_t pts, AVRational pixel_aspect);34 int64_t pts);
35 35
36int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,36int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
37 int64_t pts, AVRational pixel_aspect, int width,37 int64_t pts, int width,
38 int height, enum PixelFormat pix_fmt,38 int height, enum PixelFormat pix_fmt,
39 const char *sws_param);39 const char *sws_param);
40 40
libavfilter/vsrc_movie.c+2−2
@@ -247,8 +247,8 @@ static int movie_get_frame(AVFilterLink *outlink) · 246 unmodified lines
247 movie->frame->pkt_dts : movie->frame->pkt_pts;247 movie->frame->pkt_dts : movie->frame->pkt_pts;
248 248
249 movie->picref->pos = movie->frame->pkt_pos;249 movie->picref->pos = movie->frame->pkt_pos;
250 movie->picref->video->pixel_aspect = st->sample_aspect_ratio.num ?250 if (!movie->frame->sample_aspect_ratio.num)
251 st->sample_aspect_ratio : movie->codec_ctx->sample_aspect_ratio;251 movie->picref->video->pixel_aspect = st->sample_aspect_ratio;
252 movie->picref->video->interlaced = movie->frame->interlaced_frame;252 movie->picref->video->interlaced = movie->frame->interlaced_frame;
253 movie->picref->video->top_field_first = movie->frame->top_field_first;253 movie->picref->video->top_field_first = movie->frame->top_field_first;
254 movie->picref->video->key_frame = movie->frame->key_frame;254 movie->picref->video->key_frame = movie->frame->key_frame;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t