History

Separate video specific BufferRef properties into VideoProps.

Define a new struct AVFilterBufferRefVideoProps and add a type field to AVFilterBufferRef. Video specific properties in AVFilterBufferRefVideoProps are now referred to by *video pointer in AVFilterBufferRef. Patch by S.N. Hemanth Meenakshisundaram smeenaks->ucsd.edu. Originally committed as revision 24763 to svn://svn.ffmpeg.org/ffmpeg/trunk

S.N. Hemanth Meenakshisundaram committed 16 years ago

Commit cc80caf1 parent fd7b11d10 files · +59 −42Browse files

Unified · Split

10 files
  1. ffmpeg.c +4 −3
  2. ffplay.c +6 −6
  3. libavfilter/avfilter.c +7 −2
  4. libavfilter/avfilter.h +22 −12
  5. libavfilter/defaults.c +7 −6
  6. libavfilter/vf_aspect.c +1 −1
  7. libavfilter/vf_crop.c +2 −2
  8. libavfilter/vf_pad.c +3 −3
  9. libavfilter/vf_scale.c +3 −3
  10. libavfilter/vsrc_buffer.c +4 −4
ffmpeg.c+4−3
@@ -377,8 +377,8 @@ static int get_filtered_video_pic(AVFilterContext *ctx, · 376 unmodified lines
377377
378378 memcpy(pic2->data, pic->data, sizeof(pic->data));
379379 memcpy(pic2->linesize, pic->linesize, sizeof(pic->linesize));
380− pic2->interlaced_frame = pic->interlaced;
381− pic2->top_field_first = pic->top_field_first;
380+ pic2->interlaced_frame = pic->video->interlaced;
381+ pic2->top_field_first = pic->video->top_field_first;
382382
383383 return 1;
384384 }
@@ -1701,7 +1701,8 @@ static int output_packet(AVInputStream *ist, int ist_index, · 1316 unmodified lines
17011701 break;
17021702 case AVMEDIA_TYPE_VIDEO:
17031703 #if CONFIG_AVFILTER
1704− ost->st->codec->sample_aspect_ratio = ist->picref->pixel_aspect;
1704+ if (ist->picref->video)
1705+ ost->st->codec->sample_aspect_ratio = ist->picref->video->pixel_aspect;
17051706 #endif
17061707 do_video_out(os, ost, ist, &picture, &frame_size);
17071708 if (vstats_filename && frame_size)
ffplay.c+6−6
@@ -694,10 +694,10 @@ static void video_image_display(VideoState *is) · 693 unmodified lines
694694 vp = &is->pictq[is->pictq_rindex];
695695 if (vp->bmp) {
696696 #if CONFIG_AVFILTER
697− if (vp->picref->pixel_aspect.num == 0)
697+ if (vp->picref->video->pixel_aspect.num == 0)
698698 aspect_ratio = 0;
699699 else
700− aspect_ratio = av_q2d(vp->picref->pixel_aspect);
700+ aspect_ratio = av_q2d(vp->picref->video->pixel_aspect);
701701 #else
702702
703703 /* XXX: use variable in the frame */
@@ -1582,8 +1582,8 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) · 878 unmodified lines
15821582 if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h)))
15831583 return -1;
15841584
1585− ref->w = codec->width;
1586− ref->h = codec->height;
1585+ ref->video->w = codec->width;
1586+ ref->video->h = codec->height;
15871587 for(i = 0; i < 4; i ++) {
15881588 unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;
15891589 unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;
@@ -1616,7 +1616,7 @@ static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) · 26 unmodified lines
16161616 return codec->get_buffer(codec, pic);
16171617 }
16181618
1619− if ((codec->width != ref->w) || (codec->height != ref->h) ||
1619+ if ((codec->width != ref->video->w) || (codec->height != ref->video->h) ||
16201620 (codec->pix_fmt != ref->format)) {
16211621 av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n");
16221622 return -1;
@@ -1677,7 +1677,7 @@ static int input_request_frame(AVFilterLink *link) · 54 unmodified lines
16771677
16781678 picref->pts = pts;
16791679 picref->pos = pkt.pos;
1680− picref->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio;
1680+ picref->video->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio;
16811681 avfilter_start_frame(link, picref);
16821682 avfilter_draw_slice(link, 0, link->h, 1);
16831683 avfilter_end_frame(link);
libavfilter/avfilter.c+7−2
@@ -49,6 +49,10 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask) · 48 unmodified lines
4949 {
5050 AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
5151 *ret = *ref;
52+ if (ref->type == AVMEDIA_TYPE_VIDEO) {
53+ ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
54+ *ret->video = *ref->video;
55+ }
5256 ret->perms &= pmask;
5357 ret->buf->refcount ++;
5458 return ret;
@@ -58,6 +62,7 @@ void avfilter_unref_buffer(AVFilterBufferRef *ref) · 3 unmodified lines
5862 {
5963 if(!(--ref->buf->refcount))
6064 ref->buf->free(ref->buf);
65+ av_free(ref->video);
6166 av_free(ref);
6267 }
6368
@@ -179,7 +184,7 @@ void ff_dprintf_picref(void *ctx, AVFilterBufferRef *picref, int end) · 115 unmodified lines
179184 picref->data [0], picref->data [1], picref->data [2], picref->data [3],
180185 picref->linesize[0], picref->linesize[1], picref->linesize[2], picref->linesize[3],
181186 picref->pts, picref->pos,
182− picref->pixel_aspect.num, picref->pixel_aspect.den, picref->w, picref->h,
187+ picref->video->pixel_aspect.num, picref->video->pixel_aspect.den, picref->video->w, picref->video->h,
183188 end ? "\n" : "");
184189 }
185190
@@ -314,7 +319,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) · 128 unmodified lines
314319
315320 for(i = 0; i < 4; i ++) {
316321 int planew =
317− ff_get_plane_bytewidth(link->format, link->cur_buf->w, i);
322+ ff_get_plane_bytewidth(link->format, link->cur_buf->video->w, i);
318323
319324 if(!src[i]) continue;
320325
libavfilter/avfilter.h+22−12
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/avutil.h"
2626
2727 #define LIBAVFILTER_VERSION_MAJOR 1
28−#define LIBAVFILTER_VERSION_MINOR 31
28+#define LIBAVFILTER_VERSION_MINOR 32
2929 #define LIBAVFILTER_VERSION_MICRO 0
3030
3131 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -88,6 +88,20 @@ typedef struct AVFilterBuffer · 56 unmodified lines
8888 #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
8989 #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
9090
91+/**
92+ * Video specific properties in a reference to an AVFilterBuffer. Since
93+ * AVFilterBufferRef is common to different media formats, video specific
94+ * per reference properties must be separated out.
95+ */
96+typedef struct AVFilterBufferRefVideoProps
97+{
98+ int w; ///< image width
99+ int h; ///< image height
100+ AVRational pixel_aspect; ///< pixel aspect ratio
101+ int interlaced; ///< is frame interlaced
102+ int top_field_first; ///< field order
103+} AVFilterBufferRefVideoProps;
104+
91105 /**
92106 * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
93107 * a buffer to, for example, crop image without any memcpy, the buffer origin
@@ -101,19 +115,15 @@ typedef struct AVFilterBufferRef · 7 unmodified lines
101115 AVFilterBuffer *buf; ///< the buffer that this is a reference to
102116 uint8_t *data[4]; ///< picture data for each plane
103117 int linesize[4]; ///< number of bytes per line
104− int w; ///< image width
105− int h; ///< image height
106118 int format; ///< media format
107119
108120 int64_t pts; ///< presentation timestamp in units of 1/AV_TIME_BASE
109121 int64_t pos; ///< byte position in stream, -1 if unknown
110122
111− AVRational pixel_aspect; ///< pixel aspect ratio
112−
113123 int perms; ///< permissions, see the AV_PERM_* flags
114124
115− int interlaced; ///< is frame interlaced
116− int top_field_first;
125+ enum AVMediaType type; ///< media type of buffer data
126+ AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
117127 } AVFilterBufferRef;
118128
119129 /**
@@ -122,13 +132,13 @@ typedef struct AVFilterBufferRef · 2 unmodified lines
122132 */
123133 static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
124134 {
135+ // copy common properties
125136 dst->pts = src->pts;
126137 dst->pos = src->pos;
127− dst->pixel_aspect = src->pixel_aspect;
128− dst->interlaced = src->interlaced;
129− dst->top_field_first = src->top_field_first;
130− dst->w = src->w;
131− dst->h = src->h;
138+
139+ switch (src->type) {
140+ case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
141+ }
132142 }
133143
134144 /**
libavfilter/defaults.c+7−6
@@ -39,9 +39,10 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 38 unmodified lines
3939 int i, tempsize;
4040 char *buf;
4141
42− ref->buf = pic;
43− ref->w = w;
44− ref->h = h;
42+ ref->buf = pic;
43+ ref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps));
44+ ref->video->w = w;
45+ ref->video->h = h;
4546
4647 /* make sure the buffer gets read permission or it's useless for output */
4748 ref->perms = perms | AV_PERM_READ;
@@ -49,15 +50,15 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 1 unmodified line
4950 pic->refcount = 1;
5051 ref->format = link->format;
5152 pic->free = avfilter_default_free_buffer;
52− av_fill_image_linesizes(pic->linesize, ref->format, ref->w);
53+ av_fill_image_linesizes(pic->linesize, ref->format, ref->video->w);
5354
5455 for (i=0; i<4;i++)
5556 pic->linesize[i] = FFALIGN(pic->linesize[i], 16);
5657
57− tempsize = av_fill_image_pointers(pic->data, ref->format, ref->h, NULL, pic->linesize);
58+ tempsize = av_fill_image_pointers(pic->data, ref->format, ref->video->h, NULL, pic->linesize);
5859 buf = av_malloc(tempsize + 16); // +2 is needed for swscaler, +16 to be
5960 // SIMD-friendly
60− av_fill_image_pointers(pic->data, ref->format, ref->h, buf, pic->linesize);
61+ av_fill_image_pointers(pic->data, ref->format, ref->video->h, buf, pic->linesize);
6162
6263 memcpy(ref->data, pic->data, 4*sizeof(pic->data[0]));
6364 memcpy(ref->linesize, pic->linesize, 4*sizeof(pic->linesize[0]));
libavfilter/vf_aspect.c+1−1
@@ -60,7 +60,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 59 unmodified lines
6060 {
6161 AspectContext *aspect = link->dst->priv;
6262
63− picref->pixel_aspect = aspect->aspect;
63+ picref->video->pixel_aspect = aspect->aspect;
6464 avfilter_start_frame(link->dst->outputs[0], picref);
6565 }
6666
libavfilter/vf_crop.c+2−2
@@ -135,8 +135,8 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 134 unmodified lines
135135 AVFilterBufferRef *ref2 = avfilter_ref_buffer(picref, ~0);
136136 int i;
137137
138− ref2->w = crop->w;
139− ref2->h = crop->h;
138+ picref->video->w = crop->w;
139+ picref->video->h = crop->h;
140140
141141 ref2->data[0] += crop->y * ref2->linesize[0];
142142 ref2->data[0] += (crop->x * crop->max_step[0]);
libavfilter/vf_pad.c+3−3
@@ -428,9 +428,9 @@ static int color_request_frame(AVFilterLink *link) · 427 unmodified lines
428428 {
429429 ColorContext *color = link->src->priv;
430430 AVFilterBufferRef *picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, color->w, color->h);
431− picref->pixel_aspect = (AVRational) {1, 1};
432− picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q);
433− picref->pos = 0;
431+ picref->video->pixel_aspect = (AVRational) {1, 1};
432+ picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q);
433+ picref->pos = 0;
434434
435435 avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
436436 draw_rectangle(picref,
libavfilter/vf_scale.c+3−3
@@ -156,9 +156,9 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 155 unmodified lines
156156
157157 outlink->out_buf = outpicref;
158158
159− av_reduce(&outpicref->pixel_aspect.num, &outpicref->pixel_aspect.den,
160− (int64_t)picref->pixel_aspect.num * outlink->h * link->w,
161− (int64_t)picref->pixel_aspect.den * outlink->w * link->h,
159+ av_reduce(&outpicref->video->pixel_aspect.num, &outpicref->video->pixel_aspect.den,
160+ (int64_t)picref->video->pixel_aspect.num * outlink->h * link->w,
161+ (int64_t)picref->video->pixel_aspect.den * outlink->w * link->h,
162162 INT_MAX);
163163
164164 scale->slice_y = 0;
libavfilter/vsrc_buffer.c+4−4
@@ -122,10 +122,10 @@ static int request_frame(AVFilterLink *link) · 121 unmodified lines
122122 av_picture_copy((AVPicture *)&picref->data, (AVPicture *)&c->frame,
123123 picref->format, link->w, link->h);
124124
125− picref->pts = c->pts;
126− picref->pixel_aspect = c->pixel_aspect;
127− picref->interlaced = c->frame.interlaced_frame;
128− picref->top_field_first = c->frame.top_field_first;
125+ picref->pts = c->pts;
126+ picref->video->pixel_aspect = c->pixel_aspect;
127+ picref->video->interlaced = c->frame.interlaced_frame;
128+ picref->video->top_field_first = c->frame.top_field_first;
129129 avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
130130 avfilter_draw_slice(link, 0, link->h, 1);
131131 avfilter_end_frame(link);

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