FFmpeg  2.8.17
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imgconvert.c
Go to the documentation of this file.
1 /*
2  * Misc image conversion routines
3  * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * misc image conversion routines
25  */
26 
27 /* TODO:
28  * - write 'ffimg' program to test all the image related stuff
29  * - move all api to slice based system
30  * - integrate deinterlacing, postprocessing and scaling in the conversion process
31  */
32 
33 #include "avcodec.h"
34 #include "imgconvert.h"
35 #include "internal.h"
36 #include "mathops.h"
37 #include "libavutil/avassert.h"
38 #include "libavutil/colorspace.h"
39 #include "libavutil/common.h"
40 #include "libavutil/pixdesc.h"
41 #include "libavutil/imgutils.h"
42 
43 void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
44 {
45  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
46  av_assert0(desc);
47  *h_shift = desc->log2_chroma_w;
48  *v_shift = desc->log2_chroma_h;
49 }
50 
52  enum AVPixelFormat src_pix_fmt,
53  int has_alpha)
54 {
55  return av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
56 }
57 
58 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
59  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
60 {
61  return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
62 }
63 
64 #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI
65 enum AVPixelFormat avcodec_find_best_pix_fmt2(const enum AVPixelFormat *pix_fmt_list,
66  enum AVPixelFormat src_pix_fmt,
67  int has_alpha, int *loss_ptr){
68  return avcodec_find_best_pix_fmt_of_list(pix_fmt_list, src_pix_fmt, has_alpha, loss_ptr);
69 }
70 #else
71 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
72  enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
73 {
74  return avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
75 }
76 #endif
77 
79  enum AVPixelFormat src_pix_fmt,
80  int has_alpha, int *loss_ptr){
81  int i;
82 
83  enum AVPixelFormat best = AV_PIX_FMT_NONE;
84  int loss;
85 
86  for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {
87  loss = loss_ptr ? *loss_ptr : 0;
88  best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, &loss);
89  }
90 
91  if (loss_ptr)
92  *loss_ptr = loss;
93  return best;
94 }
95 
96 /* 2x2 -> 1x1 */
97 void ff_shrink22(uint8_t *dst, int dst_wrap,
98  const uint8_t *src, int src_wrap,
99  int width, int height)
100 {
101  int w;
102  const uint8_t *s1, *s2;
103  uint8_t *d;
104 
105  for(;height > 0; height--) {
106  s1 = src;
107  s2 = s1 + src_wrap;
108  d = dst;
109  for(w = width;w >= 4; w-=4) {
110  d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
111  d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
112  d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
113  d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
114  s1 += 8;
115  s2 += 8;
116  d += 4;
117  }
118  for(;w > 0; w--) {
119  d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
120  s1 += 2;
121  s2 += 2;
122  d++;
123  }
124  src += 2 * src_wrap;
125  dst += dst_wrap;
126  }
127 }
128 
129 /* 4x4 -> 1x1 */
130 void ff_shrink44(uint8_t *dst, int dst_wrap,
131  const uint8_t *src, int src_wrap,
132  int width, int height)
133 {
134  int w;
135  const uint8_t *s1, *s2, *s3, *s4;
136  uint8_t *d;
137 
138  for(;height > 0; height--) {
139  s1 = src;
140  s2 = s1 + src_wrap;
141  s3 = s2 + src_wrap;
142  s4 = s3 + src_wrap;
143  d = dst;
144  for(w = width;w > 0; w--) {
145  d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
146  s2[0] + s2[1] + s2[2] + s2[3] +
147  s3[0] + s3[1] + s3[2] + s3[3] +
148  s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
149  s1 += 4;
150  s2 += 4;
151  s3 += 4;
152  s4 += 4;
153  d++;
154  }
155  src += 4 * src_wrap;
156  dst += dst_wrap;
157  }
158 }
159 
160 /* 8x8 -> 1x1 */
161 void ff_shrink88(uint8_t *dst, int dst_wrap,
162  const uint8_t *src, int src_wrap,
163  int width, int height)
164 {
165  int w, i;
166 
167  for(;height > 0; height--) {
168  for(w = width;w > 0; w--) {
169  int tmp=0;
170  for(i=0; i<8; i++){
171  tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
172  src += src_wrap;
173  }
174  *(dst++) = (tmp + 32)>>6;
175  src += 8 - 8*src_wrap;
176  }
177  src += 8*src_wrap - 8*width;
178  dst += dst_wrap - width;
179  }
180 }
181 
182 /* return true if yuv planar */
183 static inline int is_yuv_planar(const AVPixFmtDescriptor *desc)
184 {
185  int i;
186  int planes[4] = { 0 };
187 
188  if ( desc->flags & AV_PIX_FMT_FLAG_RGB
189  || !(desc->flags & AV_PIX_FMT_FLAG_PLANAR))
190  return 0;
191 
192  /* set the used planes */
193  for (i = 0; i < desc->nb_components; i++)
194  planes[desc->comp[i].plane] = 1;
195 
196  /* if there is an unused plane, the format is not planar */
197  for (i = 0; i < desc->nb_components; i++)
198  if (!planes[i])
199  return 0;
200  return 1;
201 }
202 
204  enum AVPixelFormat pix_fmt, int top_band, int left_band)
205 {
206  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
207  int y_shift;
208  int x_shift;
209  int max_step[4];
210 
211  if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
212  return -1;
213 
214  y_shift = desc->log2_chroma_h;
215  x_shift = desc->log2_chroma_w;
216  av_image_fill_max_pixsteps(max_step, NULL, desc);
217 
218  if (is_yuv_planar(desc)) {
219  dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
220  dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
221  dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
222  } else{
223  if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
224  return -1;
225  dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + (left_band * max_step[0]);
226  }
227 
228  dst->linesize[0] = src->linesize[0];
229  dst->linesize[1] = src->linesize[1];
230  dst->linesize[2] = src->linesize[2];
231  return 0;
232 }
233 
234 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
235  enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
236  int *color)
237 {
238  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
239  uint8_t *optr;
240  int y_shift;
241  int x_shift;
242  int yheight;
243  int i, y;
244  int max_step[4];
245 
246  if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
247  return -1;
248 
249  if (!is_yuv_planar(desc)) {
250  if (src)
251  return -1; //TODO: Not yet implemented
252 
253  av_image_fill_max_pixsteps(max_step, NULL, desc);
254 
255  if (padtop || padleft) {
256  memset(dst->data[0], color[0],
257  dst->linesize[0] * padtop + (padleft * max_step[0]));
258  }
259 
260  if (padleft || padright) {
261  optr = dst->data[0] + dst->linesize[0] * padtop +
262  (dst->linesize[0] - (padright * max_step[0]));
263  yheight = height - 1 - (padtop + padbottom);
264  for (y = 0; y < yheight; y++) {
265  memset(optr, color[0], (padleft + padright) * max_step[0]);
266  optr += dst->linesize[0];
267  }
268  }
269 
270  if (padbottom || padright) {
271  optr = dst->data[0] + dst->linesize[0] * (height - padbottom) -
272  (padright * max_step[0]);
273  memset(optr, color[0], dst->linesize[0] * padbottom +
274  (padright * max_step[0]));
275  }
276 
277  return 0;
278  }
279 
280  for (i = 0; i < 3; i++) {
281  x_shift = i ? desc->log2_chroma_w : 0;
282  y_shift = i ? desc->log2_chroma_h : 0;
283 
284  if (padtop || padleft) {
285  memset(dst->data[i], color[i],
286  dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
287  }
288 
289  if (padleft || padright) {
290  optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
291  (dst->linesize[i] - (padright >> x_shift));
292  yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
293  for (y = 0; y < yheight; y++) {
294  memset(optr, color[i], (padleft + padright) >> x_shift);
295  optr += dst->linesize[i];
296  }
297  }
298 
299  if (src) { /* first line */
300  uint8_t *iptr = src->data[i];
301  optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
302  (padleft >> x_shift);
303  memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
304  iptr += src->linesize[i];
305  optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
306  (dst->linesize[i] - (padright >> x_shift));
307  yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
308  for (y = 0; y < yheight; y++) {
309  memset(optr, color[i], (padleft + padright) >> x_shift);
310  memcpy(optr + ((padleft + padright) >> x_shift), iptr,
311  (width - padleft - padright) >> x_shift);
312  iptr += src->linesize[i];
313  optr += dst->linesize[i];
314  }
315  }
316 
317  if (padbottom || padright) {
318  optr = dst->data[i] + dst->linesize[i] *
319  ((height - padbottom) >> y_shift) - (padright >> x_shift);
320  memset(optr, color[i],dst->linesize[i] *
321  (padbottom >> y_shift) + (padright >> x_shift));
322  }
323  }
324 
325  return 0;
326 }
327 
328 #if FF_API_DEINTERLACE
329 
330 #if HAVE_MMX_EXTERNAL
331 #define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
332 #define deinterlace_line ff_deinterlace_line_mmx
333 #else
334 #define deinterlace_line_inplace deinterlace_line_inplace_c
335 #define deinterlace_line deinterlace_line_c
336 
337 /* filter parameters: [-1 4 2 4 -1] // 8 */
338 static void deinterlace_line_c(uint8_t *dst,
339  const uint8_t *lum_m4, const uint8_t *lum_m3,
340  const uint8_t *lum_m2, const uint8_t *lum_m1,
341  const uint8_t *lum,
342  int size)
343 {
344  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
345  int sum;
346 
347  for(;size > 0;size--) {
348  sum = -lum_m4[0];
349  sum += lum_m3[0] << 2;
350  sum += lum_m2[0] << 1;
351  sum += lum_m1[0] << 2;
352  sum += -lum[0];
353  dst[0] = cm[(sum + 4) >> 3];
354  lum_m4++;
355  lum_m3++;
356  lum_m2++;
357  lum_m1++;
358  lum++;
359  dst++;
360  }
361 }
362 
363 static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3,
364  uint8_t *lum_m2, uint8_t *lum_m1,
365  uint8_t *lum, int size)
366 {
367  const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
368  int sum;
369 
370  for(;size > 0;size--) {
371  sum = -lum_m4[0];
372  sum += lum_m3[0] << 2;
373  sum += lum_m2[0] << 1;
374  lum_m4[0]=lum_m2[0];
375  sum += lum_m1[0] << 2;
376  sum += -lum[0];
377  lum_m2[0] = cm[(sum + 4) >> 3];
378  lum_m4++;
379  lum_m3++;
380  lum_m2++;
381  lum_m1++;
382  lum++;
383  }
384 }
385 #endif /* !HAVE_MMX_EXTERNAL */
386 
387 /* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
388  top field is copied as is, but the bottom field is deinterlaced
389  against the top field. */
390 static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
391  const uint8_t *src1, int src_wrap,
392  int width, int height)
393 {
394  const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
395  int y;
396 
397  src_m2 = src1;
398  src_m1 = src1;
399  src_0=&src_m1[src_wrap];
400  src_p1=&src_0[src_wrap];
401  src_p2=&src_p1[src_wrap];
402  for(y=0;y<(height-2);y+=2) {
403  memcpy(dst,src_m1,width);
404  dst += dst_wrap;
405  deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width);
406  src_m2 = src_0;
407  src_m1 = src_p1;
408  src_0 = src_p2;
409  src_p1 += 2*src_wrap;
410  src_p2 += 2*src_wrap;
411  dst += dst_wrap;
412  }
413  memcpy(dst,src_m1,width);
414  dst += dst_wrap;
415  /* do last line */
416  deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width);
417 }
418 
420  int width, int height)
421 {
422  uint8_t *src_m1, *src_0, *src_p1, *src_p2;
423  int y;
424  uint8_t *buf;
425  buf = av_malloc(width);
426  if (!buf)
427  return AVERROR(ENOMEM);
428 
429  src_m1 = src1;
430  memcpy(buf,src_m1,width);
431  src_0=&src_m1[src_wrap];
432  src_p1=&src_0[src_wrap];
433  src_p2=&src_p1[src_wrap];
434  for(y=0;y<(height-2);y+=2) {
435  deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width);
436  src_m1 = src_p1;
437  src_0 = src_p2;
438  src_p1 += 2*src_wrap;
439  src_p2 += 2*src_wrap;
440  }
441  /* do last line */
442  deinterlace_line_inplace(buf,src_m1,src_0,src_0,src_0,width);
443  av_free(buf);
444  return 0;
445 }
446 
448  enum AVPixelFormat pix_fmt, int width, int height)
449 {
450  int i, ret;
451 
452  if (pix_fmt != AV_PIX_FMT_YUV420P &&
453  pix_fmt != AV_PIX_FMT_YUVJ420P &&
454  pix_fmt != AV_PIX_FMT_YUV422P &&
455  pix_fmt != AV_PIX_FMT_YUVJ422P &&
456  pix_fmt != AV_PIX_FMT_YUV444P &&
457  pix_fmt != AV_PIX_FMT_YUV411P &&
458  pix_fmt != AV_PIX_FMT_GRAY8)
459  return -1;
460  if ((width & 3) != 0 || (height & 3) != 0)
461  return -1;
462 
463  for(i=0;i<3;i++) {
464  if (i == 1) {
465  switch(pix_fmt) {
466  case AV_PIX_FMT_YUVJ420P:
467  case AV_PIX_FMT_YUV420P:
468  width >>= 1;
469  height >>= 1;
470  break;
471  case AV_PIX_FMT_YUV422P:
472  case AV_PIX_FMT_YUVJ422P:
473  width >>= 1;
474  break;
475  case AV_PIX_FMT_YUV411P:
476  width >>= 2;
477  break;
478  default:
479  break;
480  }
481  if (pix_fmt == AV_PIX_FMT_GRAY8) {
482  break;
483  }
484  }
485  if (src == dst) {
487  dst->linesize[i],
488  width, height);
489  if (ret < 0)
490  return ret;
491  } else {
492  deinterlace_bottom_field(dst->data[i],dst->linesize[i],
493  src->data[i], src->linesize[i],
494  width, height);
495  }
496  }
497  emms_c();
498  return 0;
499 }
500 
501 #endif /* FF_API_DEINTERLACE */
502 
503 #ifdef TEST
504 
505 int main(void){
506  int i;
507  int err=0;
508  int skip = 0;
509 
510  for (i=0; i<AV_PIX_FMT_NB*2; i++) {
511  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
512  if(!desc || !desc->name) {
513  skip ++;
514  continue;
515  }
516  if (skip) {
517  av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip);
518  skip = 0;
519  }
520  av_log(NULL, AV_LOG_INFO, "pix fmt %s yuv_plan:%d avg_bpp:%d\n", desc->name, is_yuv_planar(desc), av_get_padded_bits_per_pixel(desc));
521  if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) {
522  av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n");
523  err = 1;
524  }
525  }
526  return err;
527 }
528 
529 #endif
#define NULL
Definition: coverity.c:32
static enum AVPixelFormat pix_fmt
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
Definition: avcodec.h:3756
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2129
#define deinterlace_line_inplace
Definition: imgconvert.c:334
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
deinterlace - if not supported return -1
Definition: imgconvert.c:447
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:72
misc image utilities
static int is_yuv_planar(const AVPixFmtDescriptor *desc)
Definition: imgconvert.c:183
#define MAX_NEG_CROP
Definition: mathops.h:30
Various defines for YUV<->RGB conversion.
int av_picture_crop(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int top_band, int left_band)
Crop image top and left side.
Definition: imgconvert.c:203
Picture data structure.
Definition: avcodec.h:3754
static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap, const uint8_t *src1, int src_wrap, int width, int height)
Definition: imgconvert.c:390
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, int has_alpha)
Definition: imgconvert.c:51
static void deinterlace_line_c(uint8_t *dst, const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
Definition: imgconvert.c:338
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition: imgutils.c:34
FFTComplex * tmp
Definition: imdct15.h:31
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:100
uint8_t
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:156
#define av_malloc(s)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
Definition: avcodec.h:3755
#define emms_c()
Definition: internal.h:53
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:80
ptrdiff_t size
Definition: opengl_enc.c:101
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
Definition: imgconvert.c:130
#define av_log(a,...)
#define cm
Definition: dvbsubdec.c:37
const char * name
Definition: pixdesc.h:70
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
#define s2
Definition: regdef.h:39
#define AVERROR(e)
Definition: error.h:43
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:131
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:2094
enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Find the best pixel format to convert to given a certain source pixel format.
Definition: imgconvert.c:78
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:71
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
Definition: imgconvert.c:161
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
Definition: imgconvert.c:97
static double lum(void *priv, double x, double y, int plane)
Definition: vf_fftfilt.c:74
float y
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:79
#define deinterlace_line
Definition: imgconvert.c:335
#define s4
Definition: regdef.h:41
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
Definition: imgconvert.c:43
#define s3
Definition: regdef.h:40
enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Definition: imgconvert.c:58
enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Definition: imgconvert.c:71
#define src1
Definition: h264pred.c:139
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
AVS_Value src
Definition: avisynth_c.h:482
uint8_t flags
Definition: pixdesc.h:90
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
void * buf
Definition: avisynth_c.h:553
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, int has_alpha)
Compute what kind of losses will occur when converting from one specific pixel format to another...
Definition: pixdesc.c:2401
#define s1
Definition: regdef.h:38
uint16_t plane
Which of the 4 planes contains the component.
Definition: pixdesc.h:34
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:67
Y , 8bpp.
Definition: pixfmt.h:75
common internal api header.
common internal and external API header
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:74
#define ff_crop_tab
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Compute what kind of losses will occur when converting from one specific pixel format to another...
Definition: pixdesc.c:2412
#define av_free(p)
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color)
Pad image.
Definition: imgconvert.c:234
static int deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap, int width, int height)
Definition: imgconvert.c:419
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
Definition: pixfmt.h:332
int main(int argc, char **argv)
Definition: main.c:22
AVPixelFormat
Pixel format.
Definition: pixfmt.h:65
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:127
static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, int size)
Definition: imgconvert.c:363
for(j=16;j >0;--j)
static int width