| OLD | NEW |
| 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 libavfilter/vf_crop.c | 22 * @file libavfilter/vf_crop.c |
| 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 | 28 |
| 28 typedef struct { | 29 typedef struct { |
| 29 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 |
| 30 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 |
| 31 int w; ///< width of the cropped area | 32 int w; ///< width of the cropped area |
| 32 int h; ///< height of the cropped area | 33 int h; ///< height of the cropped area |
| 33 | 34 |
| 34 int bpp; ///< bits per pixel | 35 int bpp; ///< bits per pixel |
| 35 int hsub, vsub; ///< chroma subsampling | 36 int hsub, vsub; ///< chroma subsampling |
| 36 } CropContext; | 37 } CropContext; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 CropContext *crop = link->dst->priv; | 167 CropContext *crop = link->dst->priv; |
| 167 AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0); | 168 AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0); |
| 168 int i; | 169 int i; |
| 169 | 170 |
| 170 ref2->w = crop->w; | 171 ref2->w = crop->w; |
| 171 ref2->h = crop->h; | 172 ref2->h = crop->h; |
| 172 | 173 |
| 173 ref2->data[0] += crop->y * ref2->linesize[0]; | 174 ref2->data[0] += crop->y * ref2->linesize[0]; |
| 174 ref2->data[0] += (crop->x * crop->bpp) >> 3; | 175 ref2->data[0] += (crop->x * crop->bpp) >> 3; |
| 175 | 176 |
| 176 if (link->format != PIX_FMT_PAL8 && | 177 if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL)) { |
| 177 link->format != PIX_FMT_BGR4_BYTE && | |
| 178 link->format != PIX_FMT_RGB4_BYTE && | |
| 179 link->format != PIX_FMT_BGR8 && | |
| 180 link->format != PIX_FMT_RGB8) { | |
| 181 for (i = 1; i < 3; i ++) { | 178 for (i = 1; i < 3; i ++) { |
| 182 if (ref2->data[i]) { | 179 if (ref2->data[i]) { |
| 183 ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i]; | 180 ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i]; |
| 184 ref2->data[i] += ((crop->x * crop->bpp) >> 3) >> crop->hsub; | 181 ref2->data[i] += ((crop->x * crop->bpp) >> 3) >> crop->hsub; |
| 185 } | 182 } |
| 186 } | 183 } |
| 187 } | 184 } |
| 188 | 185 |
| 189 /* alpha plane */ | 186 /* alpha plane */ |
| 190 if (ref2->data[3]) { | 187 if (ref2->data[3]) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 .start_frame = start_frame, | 224 .start_frame = start_frame, |
| 228 .draw_slice = draw_slice, | 225 .draw_slice = draw_slice, |
| 229 .get_video_buffer = get_video_buffer, | 226 .get_video_buffer = get_video_buffer, |
| 230 .config_props = config_input, }, | 227 .config_props = config_input, }, |
| 231 { .name = NULL}}, | 228 { .name = NULL}}, |
| 232 .outputs = (AVFilterPad[]) {{ .name = "default", | 229 .outputs = (AVFilterPad[]) {{ .name = "default", |
| 233 .type = CODEC_TYPE_VIDEO, | 230 .type = CODEC_TYPE_VIDEO, |
| 234 .config_props = config_output, }, | 231 .config_props = config_output, }, |
| 235 { .name = NULL}}, | 232 { .name = NULL}}, |
| 236 }; | 233 }; |
| OLD | NEW |