Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: source/patched-ffmpeg-mt/libavfilter/vf_crop.c

Issue 3384002: ffmpeg source update for sep 09 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * copyright (c) 2007 Bobby Bingham 2 * copyright (c) 2007 Bobby Bingham
3 * 3 *
4 * This file is part of FFmpeg. 4 * This file is part of FFmpeg.
5 * 5 *
6 * FFmpeg is free software; you can redistribute it and/or 6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public 7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version. 9 * version 2.1 of the License, or (at your option) any later version.
10 * 10 *
11 * FFmpeg is distributed in the hope that it will be useful, 11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details. 14 * Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software 17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20 20
21 /** 21 /**
22 * @file 22 * @file
23 * video crop filter 23 * video crop filter
24 */ 24 */
25 25
26 #include "avfilter.h" 26 #include "avfilter.h"
27 #include "libavutil/pixdesc.h" 27 #include "libavcore/imgutils.h"
28 28
29 typedef struct { 29 typedef struct {
30 int x; ///< x offset of the non-cropped area with respect to th e input area 30 int x; ///< x offset of the non-cropped area with respect to th e input area
31 int y; ///< y offset of the non-cropped area with respect to th e input area 31 int y; ///< y offset of the non-cropped area with respect to th e input area
32 int w; ///< width of the cropped area 32 int w; ///< width of the cropped area
33 int h; ///< height of the cropped area 33 int h; ///< height of the cropped area
34 34
35 int max_step[4]; ///< max pixel step for each plane, expressed as a numbe r of bytes 35 int max_step[4]; ///< max pixel step for each plane, expressed as a numbe r of bytes
36 int hsub, vsub; ///< chroma subsampling 36 int hsub, vsub; ///< chroma subsampling
37 } CropContext; 37 } CropContext;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 sscanf(args, "%d:%d:%d:%d", &crop->x, &crop->y, &crop->w, &crop->h); 76 sscanf(args, "%d:%d:%d:%d", &crop->x, &crop->y, &crop->w, &crop->h);
77 77
78 return 0; 78 return 0;
79 } 79 }
80 80
81 static int config_input(AVFilterLink *link) 81 static int config_input(AVFilterLink *link)
82 { 82 {
83 AVFilterContext *ctx = link->dst; 83 AVFilterContext *ctx = link->dst;
84 CropContext *crop = ctx->priv; 84 CropContext *crop = ctx->priv;
85 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[link->format]; 85 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[link->format];
86 int i;
87 86
88 memset(crop->max_step, 0, sizeof(crop->max_step)); 87 av_image_fill_max_pixsteps(crop->max_step, NULL, pix_desc);
89 for (i = 0; i < 4; i++) {
90 const AVComponentDescriptor *comp = &(pix_desc->comp[i]);
91 if ((comp->step_minus1+1) > crop->max_step[comp->plane])
92 crop->max_step[comp->plane] = comp->step_minus1+1;
93 }
94
95 crop->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; 88 crop->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w;
96 crop->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; 89 crop->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
97 90
98 if (crop->w == 0) 91 if (crop->w == 0)
99 crop->w = link->w - crop->x; 92 crop->w = link->w - crop->x;
100 if (crop->h == 0) 93 if (crop->h == 0)
101 crop->h = link->h - crop->y; 94 crop->h = link->h - crop->y;
102 95
103 crop->x &= ~((1 << crop->hsub) - 1); 96 crop->x &= ~((1 << crop->hsub) - 1);
104 crop->y &= ~((1 << crop->vsub) - 1); 97 crop->y &= ~((1 << crop->vsub) - 1);
(...skipping 23 matching lines...) Expand all
128 121
129 return 0; 122 return 0;
130 } 123 }
131 124
132 static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) 125 static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
133 { 126 {
134 CropContext *crop = link->dst->priv; 127 CropContext *crop = link->dst->priv;
135 AVFilterBufferRef *ref2 = avfilter_ref_buffer(picref, ~0); 128 AVFilterBufferRef *ref2 = avfilter_ref_buffer(picref, ~0);
136 int i; 129 int i;
137 130
138 ref2->w = crop->w; 131 picref->video->w = crop->w;
139 ref2->h = crop->h; 132 picref->video->h = crop->h;
140 133
141 ref2->data[0] += crop->y * ref2->linesize[0]; 134 ref2->data[0] += crop->y * ref2->linesize[0];
142 ref2->data[0] += (crop->x * crop->max_step[0]); 135 ref2->data[0] += (crop->x * crop->max_step[0]);
143 136
144 if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) { 137 if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) {
145 for (i = 1; i < 3; i ++) { 138 for (i = 1; i < 3; i ++) {
146 if (ref2->data[i]) { 139 if (ref2->data[i]) {
147 ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i]; 140 ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
148 ref2->data[i] += (crop->x * crop->max_step[i]) >> crop->hsub; 141 ref2->data[i] += (crop->x * crop->max_step[i]) >> crop->hsub;
149 } 142 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 .start_frame = start_frame, 184 .start_frame = start_frame,
192 .draw_slice = draw_slice, 185 .draw_slice = draw_slice,
193 .get_video_buffer = avfilter_null_get_video_ buffer, 186 .get_video_buffer = avfilter_null_get_video_ buffer,
194 .config_props = config_input, }, 187 .config_props = config_input, },
195 { .name = NULL}}, 188 { .name = NULL}},
196 .outputs = (AVFilterPad[]) {{ .name = "default", 189 .outputs = (AVFilterPad[]) {{ .name = "default",
197 .type = AVMEDIA_TYPE_VIDEO, 190 .type = AVMEDIA_TYPE_VIDEO,
198 .config_props = config_output, }, 191 .config_props = config_output, },
199 { .name = NULL}}, 192 { .name = NULL}},
200 }; 193 };
OLDNEW
« no previous file with comments | « source/patched-ffmpeg-mt/libavfilter/vf_aspect.c ('k') | source/patched-ffmpeg-mt/libavfilter/vf_fifo.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698