avfilter_(un)ref_pic -> avfilter_(un)ref_buffer avfilter_copy_picref_props -> avfilter_copy_buffer_ref_props AVFilterBufferRef.pic -> AVFilterBufferRef.buffer They have been renamed to allow sharing with audio. Patch by S.N. Hemanth Meenakshisundaram $smeenaks$ucsd$edu$. Originally committed as revision 24731 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -1777,7 +1777,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 1776 unmodified lines | ||
| 1777 | 1777 | frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && |
| 1778 | 1778 | ist->out_video_filter && avfilter_poll_frame(ist->out_video_filter->inputs[0]); |
| 1779 | 1779 | if(ist->picref) |
| 1780 | − avfilter_unref_pic(ist->picref); | |
| 1780 | + avfilter_unref_buffer(ist->picref); | |
| 1781 | 1781 | } |
| 1782 | 1782 | #endif |
| 1783 | 1783 | av_free(buffer_to_free); |
| @@ -1304,7 +1304,7 @@ static void alloc_picture(void *opaque) · 1303 unmodified lines | ||
| 1304 | 1304 | |
| 1305 | 1305 | #if CONFIG_AVFILTER |
| 1306 | 1306 | if (vp->picref) |
| 1307 | − avfilter_unref_pic(vp->picref); | |
| 1307 | + avfilter_unref_buffer(vp->picref); | |
| 1308 | 1308 | vp->picref = NULL; |
| 1309 | 1309 | |
| 1310 | 1310 | vp->width = is->out_video_filter->inputs[0]->w; |
| @@ -1389,7 +1389,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t · 78 unmodified lines | ||
| 1389 | 1389 | AVPicture pict; |
| 1390 | 1390 | #if CONFIG_AVFILTER |
| 1391 | 1391 | if(vp->picref) |
| 1392 | − avfilter_unref_pic(vp->picref); | |
| 1392 | + avfilter_unref_buffer(vp->picref); | |
| 1393 | 1393 | vp->picref = src_frame->opaque; |
| 1394 | 1394 | #endif |
| 1395 | 1395 | |
| @@ -1604,7 +1604,7 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) · 208 unmodified lines | ||
| 1604 | 1604 | static void input_release_buffer(AVCodecContext *codec, AVFrame *pic) |
| 1605 | 1605 | { |
| 1606 | 1606 | memset(pic->data, 0, sizeof(pic->data)); |
| 1607 | − avfilter_unref_pic(pic->opaque); | |
| 1607 | + avfilter_unref_buffer(pic->opaque); | |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic) |
| @@ -1667,7 +1667,7 @@ static int input_request_frame(AVFilterLink *link) · 56 unmodified lines | ||
| 1667 | 1667 | return -1; |
| 1668 | 1668 | |
| 1669 | 1669 | if(priv->use_dr1) { |
| 1670 | − picref = avfilter_ref_pic(priv->frame->opaque, ~0); | |
| 1670 | + picref = avfilter_ref_buffer(priv->frame->opaque, ~0); | |
| 1671 | 1671 | } else { |
| 1672 | 1672 | picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h); |
| 1673 | 1673 | av_picture_copy((AVPicture *)&picref->data, (AVPicture *)priv->frame, |
| @@ -2672,7 +2672,7 @@ static void stream_close(VideoState *is) · 998 unmodified lines | ||
| 2672 | 2672 | vp = &is->pictq[i]; |
| 2673 | 2673 | #if CONFIG_AVFILTER |
| 2674 | 2674 | if (vp->picref) { |
| 2675 | − avfilter_unref_pic(vp->picref); | |
| 2675 | + avfilter_unref_buffer(vp->picref); | |
| 2676 | 2676 | vp->picref = NULL; |
| 2677 | 2677 | } |
| 2678 | 2678 | #endif |
| @@ -45,19 +45,19 @@ const char *avfilter_license(void) · 44 unmodified lines | ||
| 45 | 45 | #define link_dpad(link) link->dst-> input_pads[link->dstpad] |
| 46 | 46 | #define link_spad(link) link->src->output_pads[link->srcpad] |
| 47 | 47 | |
| 48 | −AVFilterBufferRef *avfilter_ref_pic(AVFilterBufferRef *ref, int pmask) | |
| 48 | +AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask) | |
| 49 | 49 | { |
| 50 | 50 | AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef)); |
| 51 | 51 | *ret = *ref; |
| 52 | 52 | ret->perms &= pmask; |
| 53 | − ret->pic->refcount ++; | |
| 53 | + ret->buf->refcount ++; | |
| 54 | 54 | return ret; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | −void avfilter_unref_pic(AVFilterBufferRef *ref) | |
| 57 | +void avfilter_unref_buffer(AVFilterBufferRef *ref) | |
| 58 | 58 | { |
| 59 | − if(!(--ref->pic->refcount)) | |
| 60 | − ref->pic->free(ref->pic); | |
| 59 | + if(!(--ref->buf->refcount)) | |
| 60 | + ref->buf->free(ref->buf); | |
| 61 | 61 | av_free(ref); |
| 62 | 62 | } |
| 63 | 63 | |
| @@ -264,7 +264,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 200 unmodified lines | ||
| 264 | 264 | |
| 265 | 265 | link->cur_pic = avfilter_default_get_video_buffer(link, dst->min_perms, link->w, link->h); |
| 266 | 266 | link->srcpic = picref; |
| 267 | − avfilter_copy_picref_props(link->cur_pic, link->srcpic); | |
| 267 | + avfilter_copy_buffer_ref_props(link->cur_pic, link->srcpic); | |
| 268 | 268 | } |
| 269 | 269 | else |
| 270 | 270 | link->cur_pic = picref; |
| @@ -284,7 +284,7 @@ void avfilter_end_frame(AVFilterLink *link) · 13 unmodified lines | ||
| 284 | 284 | /* unreference the source picture if we're feeding the destination filter |
| 285 | 285 | * a copied version dues to permission issues */ |
| 286 | 286 | if(link->srcpic) { |
| 287 | − avfilter_unref_pic(link->srcpic); | |
| 287 | + avfilter_unref_buffer(link->srcpic); | |
| 288 | 288 | link->srcpic = NULL; |
| 289 | 289 | } |
| 290 | 290 | |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "libavutil/avutil.h" |
| 26 | 26 | |
| 27 | 27 | #define LIBAVFILTER_VERSION_MAJOR 1 |
| 28 | −#define LIBAVFILTER_VERSION_MINOR 29 | |
| 28 | +#define LIBAVFILTER_VERSION_MINOR 30 | |
| 29 | 29 | #define LIBAVFILTER_VERSION_MICRO 0 |
| 30 | 30 | |
| 31 | 31 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| @@ -90,7 +90,7 @@ typedef struct AVFilterBuffer · 58 unmodified lines | ||
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * A reference to an AVFilterBuffer. Since filters can manipulate the origin of |
| 93 | − * a picture to, for example, crop image without any memcpy, the picture origin | |
| 93 | + * a buffer to, for example, crop image without any memcpy, the buffer origin | |
| 94 | 94 | * and dimensions are per-reference properties. Linesize is also useful for |
| 95 | 95 | * image flipping, frame to field filters, etc, and so is also per-reference. |
| 96 | 96 | * |
| @@ -98,7 +98,7 @@ typedef struct AVFilterBuffer · 1 unmodified line | ||
| 98 | 98 | */ |
| 99 | 99 | typedef struct AVFilterBufferRef |
| 100 | 100 | { |
| 101 | − AVFilterBuffer *pic; ///< the picture that this is a reference to | |
| 101 | + AVFilterBuffer *buf; ///< the buffer that this is a reference to | |
| 102 | 102 | uint8_t *data[4]; ///< picture data for each plane |
| 103 | 103 | int linesize[4]; ///< number of bytes per line |
| 104 | 104 | int w; ///< image width |
| @@ -120,7 +120,7 @@ typedef struct AVFilterBufferRef · 15 unmodified lines | ||
| 120 | 120 | * Copy properties of src to dst, without copying the actual video |
| 121 | 121 | * data. |
| 122 | 122 | */ |
| 123 | −static inline void avfilter_copy_picref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) | |
| 123 | +static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) | |
| 124 | 124 | { |
| 125 | 125 | dst->pts = src->pts; |
| 126 | 126 | dst->pos = src->pos; |
| @@ -132,21 +132,21 @@ static inline void avfilter_copy_picref_props(AVFilterBufferRef *dst, AVFilterBu · 5 unmodified lines | ||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | − * Add a new reference to a picture. | |
| 136 | − * @param ref an existing reference to the picture | |
| 135 | + * Add a new reference to a buffer. | |
| 136 | + * @param ref an existing reference to the buffer | |
| 137 | 137 | * @param pmask a bitmask containing the allowable permissions in the new |
| 138 | 138 | * reference |
| 139 | − * @return a new reference to the picture with the same properties as the | |
| 139 | + * @return a new reference to the buffer with the same properties as the | |
| 140 | 140 | * old, excluding any permissions denied by pmask |
| 141 | 141 | */ |
| 142 | −AVFilterBufferRef *avfilter_ref_pic(AVFilterBufferRef *ref, int pmask); | |
| 142 | +AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); | |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | − * Remove a reference to a picture. If this is the last reference to the | |
| 146 | − * picture, the picture itself is also automatically freed. | |
| 147 | − * @param ref reference to the picture | |
| 145 | + * Remove a reference to a buffer. If this is the last reference to the | |
| 146 | + * buffer, the buffer itself is also automatically freed. | |
| 147 | + * @param ref reference to the buffer | |
| 148 | 148 | */ |
| 149 | −void avfilter_unref_pic(AVFilterBufferRef *ref); | |
| 149 | +void avfilter_unref_buffer(AVFilterBufferRef *ref); | |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * A list of supported formats for one end of a filter link. This is used |
| @@ -442,7 +442,7 @@ typedef struct AVFilter · 289 unmodified lines | ||
| 442 | 442 | |
| 443 | 443 | /** |
| 444 | 444 | * Filter uninitialization function. Should deallocate any memory held |
| 445 | − * by the filter, release any picture references, etc. This does not need | |
| 445 | + * by the filter, release any buffer references, etc. This does not need | |
| 446 | 446 | * to deallocate the AVFilterContext->priv memory itself. |
| 447 | 447 | */ |
| 448 | 448 | void (*uninit)(AVFilterContext *ctx); |
| @@ -524,9 +524,9 @@ struct AVFilterLink · 75 unmodified lines | ||
| 524 | 524 | AVFilterFormats *out_formats; |
| 525 | 525 | |
| 526 | 526 | /** |
| 527 | − * The picture reference currently being sent across the link by the source | |
| 527 | + * The buffer reference currently being sent across the link by the source | |
| 528 | 528 | * filter. This is used internally by the filter system to allow |
| 529 | − * automatic copying of pictures which do not have sufficient permissions | |
| 529 | + * automatic copying of buffers which do not have sufficient permissions | |
| 530 | 530 | * for the destination. This should not be accessed directly by the |
| 531 | 531 | * filters. |
| 532 | 532 | */ |
| @@ -556,13 +556,13 @@ int avfilter_config_links(AVFilterContext *filter); · 23 unmodified lines | ||
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | 558 | * Request a picture buffer with a specific set of permissions. |
| 559 | − * @param link the output link to the filter from which the picture will | |
| 559 | + * @param link the output link to the filter from which the buffer will | |
| 560 | 560 | * be requested |
| 561 | 561 | * @param perms the required access permissions |
| 562 | 562 | * @param w the minimum width of the buffer to allocate |
| 563 | 563 | * @param h the minimum height of the buffer to allocate |
| 564 | − * @return A reference to the picture. This must be unreferenced with | |
| 565 | − * avfilter_unref_pic when you are finished with it. | |
| 564 | + * @return A reference to the buffer. This must be unreferenced with | |
| 565 | + * avfilter_unref_buffer when you are finished with it. | |
| 566 | 566 | */ |
| 567 | 567 | AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, |
| 568 | 568 | int w, int h); |
| @@ -39,7 +39,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per · 38 unmodified lines | ||
| 39 | 39 | int i, tempsize; |
| 40 | 40 | char *buf; |
| 41 | 41 | |
| 42 | − ref->pic = pic; | |
| 42 | + ref->buf = pic; | |
| 43 | 43 | ref->w = w; |
| 44 | 44 | ref->h = h; |
| 45 | 45 | |
| @@ -74,8 +74,8 @@ void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 28 unmodified lines | ||
| 74 | 74 | |
| 75 | 75 | if(out) { |
| 76 | 76 | out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, out->w, out->h); |
| 77 | − avfilter_copy_picref_props(out->outpic, picref); | |
| 78 | − avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); | |
| 77 | + avfilter_copy_buffer_ref_props(out->outpic, picref); | |
| 78 | + avfilter_start_frame(out, avfilter_ref_buffer(out->outpic, ~0)); | |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| @@ -97,12 +97,12 @@ void avfilter_default_end_frame(AVFilterLink *link) · 15 unmodified lines | ||
| 97 | 97 | if(link->dst->output_count) |
| 98 | 98 | out = link->dst->outputs[0]; |
| 99 | 99 | |
| 100 | − avfilter_unref_pic(link->cur_pic); | |
| 100 | + avfilter_unref_buffer(link->cur_pic); | |
| 101 | 101 | link->cur_pic = NULL; |
| 102 | 102 | |
| 103 | 103 | if(out) { |
| 104 | 104 | if(out->outpic) { |
| 105 | − avfilter_unref_pic(out->outpic); | |
| 105 | + avfilter_unref_buffer(out->outpic); | |
| 106 | 106 | out->outpic = NULL; |
| 107 | 107 | } |
| 108 | 108 | avfilter_end_frame(out); |
| @@ -132,7 +132,7 @@ static int config_output(AVFilterLink *link) · 131 unmodified lines | ||
| 132 | 132 | static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) |
| 133 | 133 | { |
| 134 | 134 | CropContext *crop = link->dst->priv; |
| 135 | − AVFilterBufferRef *ref2 = avfilter_ref_pic(picref, ~0); | |
| 135 | + AVFilterBufferRef *ref2 = avfilter_ref_buffer(picref, ~0); | |
| 136 | 136 | int i; |
| 137 | 137 | |
| 138 | 138 | ref2->w = crop->w; |
| @@ -244,7 +244,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int · 243 unmodified lines | ||
| 244 | 244 | static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
| 245 | 245 | { |
| 246 | 246 | PadContext *pad = inlink->dst->priv; |
| 247 | − AVFilterBufferRef *outpicref = avfilter_ref_pic(inpicref, ~0); | |
| 247 | + AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); | |
| 248 | 248 | int plane; |
| 249 | 249 | |
| 250 | 250 | inlink->dst->outputs[0]->outpic = outpicref; |
| @@ -263,7 +263,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) · 12 unmodified lines | ||
| 263 | 263 | static void end_frame(AVFilterLink *link) |
| 264 | 264 | { |
| 265 | 265 | avfilter_end_frame(link->dst->outputs[0]); |
| 266 | − avfilter_unref_pic(link->cur_pic); | |
| 266 | + avfilter_unref_buffer(link->cur_pic); | |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) |
| @@ -432,13 +432,13 @@ static int color_request_frame(AVFilterLink *link) · 162 unmodified lines | ||
| 432 | 432 | picref->pts = av_rescale_q(color->pts++, color->time_base, AV_TIME_BASE_Q); |
| 433 | 433 | picref->pos = 0; |
| 434 | 434 | |
| 435 | − avfilter_start_frame(link, avfilter_ref_pic(picref, ~0)); | |
| 435 | + avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); | |
| 436 | 436 | draw_rectangle(picref, |
| 437 | 437 | color->line, color->line_step, color->hsub, color->vsub, |
| 438 | 438 | 0, 0, color->w, color->h); |
| 439 | 439 | avfilter_draw_slice(link, 0, color->h, 1); |
| 440 | 440 | avfilter_end_frame(link); |
| 441 | − avfilter_unref_pic(picref); | |
| 441 | + avfilter_unref_buffer(picref); | |
| 442 | 442 | |
| 443 | 443 | return 0; |
| 444 | 444 | } |
| @@ -58,7 +58,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 57 unmodified lines | ||
| 58 | 58 | outlink->outpic = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, |
| 59 | 59 | outlink->w, outlink->h); |
| 60 | 60 | outpicref = outlink->outpic; |
| 61 | − avfilter_copy_picref_props(outpicref, picref); | |
| 61 | + avfilter_copy_buffer_ref_props(outpicref, picref); | |
| 62 | 62 | |
| 63 | 63 | for (i = 0; i < 4; i++) { |
| 64 | 64 | int h = outlink->h; |
| @@ -74,7 +74,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) · 9 unmodified lines | ||
| 74 | 74 | if (priv->pix_desc->flags & PIX_FMT_PAL) |
| 75 | 75 | memcpy(outpicref->data[1], outpicref->data[1], 256*4); |
| 76 | 76 | |
| 77 | − avfilter_start_frame(outlink, avfilter_ref_pic(outpicref, ~0)); | |
| 77 | + avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
| @@ -152,7 +152,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 151 unmodified lines | ||
| 152 | 152 | scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; |
| 153 | 153 | |
| 154 | 154 | outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); |
| 155 | − avfilter_copy_picref_props(outpicref, picref); | |
| 155 | + avfilter_copy_buffer_ref_props(outpicref, picref); | |
| 156 | 156 | |
| 157 | 157 | outlink->outpic = outpicref; |
| 158 | 158 | |
| @@ -162,7 +162,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) · 3 unmodified lines | ||
| 162 | 162 | INT_MAX); |
| 163 | 163 | |
| 164 | 164 | scale->slice_y = 0; |
| 165 | − avfilter_start_frame(outlink, avfilter_ref_pic(outpicref, ~0)); | |
| 165 | + avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| @@ -202,10 +202,10 @@ static void end_frame(AVFilterLink *link) · 201 unmodified lines | ||
| 202 | 202 | unsharpen(out->data[1], in->data[1], out->linesize[1], in->linesize[1], CHROMA_WIDTH(link), CHROMA_HEIGHT(link), &unsharp->chroma); |
| 203 | 203 | unsharpen(out->data[2], in->data[2], out->linesize[2], in->linesize[2], CHROMA_WIDTH(link), CHROMA_HEIGHT(link), &unsharp->chroma); |
| 204 | 204 | |
| 205 | − avfilter_unref_pic(in); | |
| 205 | + avfilter_unref_buffer(in); | |
| 206 | 206 | avfilter_draw_slice(link->dst->outputs[0], 0, link->h, 1); |
| 207 | 207 | avfilter_end_frame(link->dst->outputs[0]); |
| 208 | − avfilter_unref_pic(out); | |
| 208 | + avfilter_unref_buffer(out); | |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) |
| @@ -126,10 +126,10 @@ static int request_frame(AVFilterLink *link) · 125 unmodified lines | ||
| 126 | 126 | picref->pixel_aspect = c->pixel_aspect; |
| 127 | 127 | picref->interlaced = c->frame.interlaced_frame; |
| 128 | 128 | picref->top_field_first = c->frame.top_field_first; |
| 129 | − avfilter_start_frame(link, avfilter_ref_pic(picref, ~0)); | |
| 129 | + avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); | |
| 130 | 130 | avfilter_draw_slice(link, 0, link->h, 1); |
| 131 | 131 | avfilter_end_frame(link); |
| 132 | − avfilter_unref_pic(picref); | |
| 132 | + avfilter_unref_buffer(picref); | |
| 133 | 133 | |
| 134 | 134 | c->has_frame = 0; |
| 135 | 135 | |