FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_transpose.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Stefano Sabatini
3  * Copyright (c) 2008 Vitor Sessak
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  * transposition filter
25  * Based on MPlayer libmpcodecs/vf_rotate.c.
26  */
27 
28 #include <stdio.h>
29 
30 #include "libavutil/imgutils.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/intreadwrite.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 
36 #include "avfilter.h"
37 #include "formats.h"
38 #include "internal.h"
39 #include "video.h"
40 
41 typedef enum {
46 
52 };
53 
54 typedef struct TransContext {
55  const AVClass *class;
56  int hsub, vsub;
57  int pixsteps[4];
58 
59  int passthrough; ///< PassthroughType, landscape passthrough mode enabled
60  int dir; ///< TransposeDir
61 
62  void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
63  uint8_t *dst, ptrdiff_t dst_linesize);
64  void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
65  uint8_t *dst, ptrdiff_t dst_linesize,
66  int w, int h);
67 } TransContext;
68 
70 {
72  int fmt, ret;
73 
74  for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
76  if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
79  desc->log2_chroma_w != desc->log2_chroma_h) &&
80  (ret = ff_add_format(&pix_fmts, fmt)) < 0)
81  return ret;
82  }
83 
84 
85  return ff_set_common_formats(ctx, pix_fmts);
86 }
87 
88 static inline void transpose_block_8_c(uint8_t *src, ptrdiff_t src_linesize,
89  uint8_t *dst, ptrdiff_t dst_linesize,
90  int w, int h)
91 {
92  int x, y;
93  for (y = 0; y < h; y++, dst += dst_linesize, src++)
94  for (x = 0; x < w; x++)
95  dst[x] = src[x*src_linesize];
96 }
97 
98 static void transpose_8x8_8_c(uint8_t *src, ptrdiff_t src_linesize,
99  uint8_t *dst, ptrdiff_t dst_linesize)
100 {
101  transpose_block_8_c(src, src_linesize, dst, dst_linesize, 8, 8);
102 }
103 
104 static inline void transpose_block_16_c(uint8_t *src, ptrdiff_t src_linesize,
105  uint8_t *dst, ptrdiff_t dst_linesize,
106  int w, int h)
107 {
108  int x, y;
109  for (y = 0; y < h; y++, dst += dst_linesize, src += 2)
110  for (x = 0; x < w; x++)
111  *((uint16_t *)(dst + 2*x)) = *((uint16_t *)(src + x*src_linesize));
112 }
113 
114 static void transpose_8x8_16_c(uint8_t *src, ptrdiff_t src_linesize,
115  uint8_t *dst, ptrdiff_t dst_linesize)
116 {
117  transpose_block_16_c(src, src_linesize, dst, dst_linesize, 8, 8);
118 }
119 
120 static inline void transpose_block_24_c(uint8_t *src, ptrdiff_t src_linesize,
121  uint8_t *dst, ptrdiff_t dst_linesize,
122  int w, int h)
123 {
124  int x, y;
125  for (y = 0; y < h; y++, dst += dst_linesize) {
126  for (x = 0; x < w; x++) {
127  int32_t v = AV_RB24(src + x*src_linesize + y*3);
128  AV_WB24(dst + 3*x, v);
129  }
130  }
131 }
132 
133 static void transpose_8x8_24_c(uint8_t *src, ptrdiff_t src_linesize,
134  uint8_t *dst, ptrdiff_t dst_linesize)
135 {
136  transpose_block_24_c(src, src_linesize, dst, dst_linesize, 8, 8);
137 }
138 
139 static inline void transpose_block_32_c(uint8_t *src, ptrdiff_t src_linesize,
140  uint8_t *dst, ptrdiff_t dst_linesize,
141  int w, int h)
142 {
143  int x, y;
144  for (y = 0; y < h; y++, dst += dst_linesize, src += 4) {
145  for (x = 0; x < w; x++)
146  *((uint32_t *)(dst + 4*x)) = *((uint32_t *)(src + x*src_linesize));
147  }
148 }
149 
150 static void transpose_8x8_32_c(uint8_t *src, ptrdiff_t src_linesize,
151  uint8_t *dst, ptrdiff_t dst_linesize)
152 {
153  transpose_block_32_c(src, src_linesize, dst, dst_linesize, 8, 8);
154 }
155 
156 static inline void transpose_block_48_c(uint8_t *src, ptrdiff_t src_linesize,
157  uint8_t *dst, ptrdiff_t dst_linesize,
158  int w, int h)
159 {
160  int x, y;
161  for (y = 0; y < h; y++, dst += dst_linesize, src += 6) {
162  for (x = 0; x < w; x++) {
163  int64_t v = AV_RB48(src + x*src_linesize);
164  AV_WB48(dst + 6*x, v);
165  }
166  }
167 }
168 
169 static void transpose_8x8_48_c(uint8_t *src, ptrdiff_t src_linesize,
170  uint8_t *dst, ptrdiff_t dst_linesize)
171 {
172  transpose_block_48_c(src, src_linesize, dst, dst_linesize, 8, 8);
173 }
174 
175 static inline void transpose_block_64_c(uint8_t *src, ptrdiff_t src_linesize,
176  uint8_t *dst, ptrdiff_t dst_linesize,
177  int w, int h)
178 {
179  int x, y;
180  for (y = 0; y < h; y++, dst += dst_linesize, src += 8)
181  for (x = 0; x < w; x++)
182  *((uint64_t *)(dst + 8*x)) = *((uint64_t *)(src + x*src_linesize));
183 }
184 
185 static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t src_linesize,
186  uint8_t *dst, ptrdiff_t dst_linesize)
187 {
188  transpose_block_64_c(src, src_linesize, dst, dst_linesize, 8, 8);
189 }
190 
191 static int config_props_output(AVFilterLink *outlink)
192 {
193  AVFilterContext *ctx = outlink->src;
194  TransContext *s = ctx->priv;
195  AVFilterLink *inlink = ctx->inputs[0];
196  const AVPixFmtDescriptor *desc_out = av_pix_fmt_desc_get(outlink->format);
197  const AVPixFmtDescriptor *desc_in = av_pix_fmt_desc_get(inlink->format);
198 
199  if (s->dir&4) {
200  av_log(ctx, AV_LOG_WARNING,
201  "dir values greater than 3 are deprecated, use the passthrough option instead\n");
202  s->dir &= 3;
204  }
205 
206  if ((inlink->w >= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
207  (inlink->w <= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
208  av_log(ctx, AV_LOG_VERBOSE,
209  "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
210  inlink->w, inlink->h, inlink->w, inlink->h);
211  return 0;
212  } else {
214  }
215 
216  s->hsub = desc_in->log2_chroma_w;
217  s->vsub = desc_in->log2_chroma_h;
218 
220 
221  outlink->w = inlink->h;
222  outlink->h = inlink->w;
223 
224  if (inlink->sample_aspect_ratio.num)
225  outlink->sample_aspect_ratio = av_div_q((AVRational) { 1, 1 },
226  inlink->sample_aspect_ratio);
227  else
228  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
229 
230  switch (s->pixsteps[0]) {
232  s->transpose_8x8 = transpose_8x8_8_c; break;
234  s->transpose_8x8 = transpose_8x8_16_c; break;
236  s->transpose_8x8 = transpose_8x8_24_c; break;
238  s->transpose_8x8 = transpose_8x8_32_c; break;
240  s->transpose_8x8 = transpose_8x8_48_c; break;
242  s->transpose_8x8 = transpose_8x8_64_c; break;
243  }
244 
245  av_log(ctx, AV_LOG_VERBOSE,
246  "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
247  inlink->w, inlink->h, s->dir, outlink->w, outlink->h,
248  s->dir == 1 || s->dir == 3 ? "clockwise" : "counterclockwise",
249  s->dir == 0 || s->dir == 3);
250  return 0;
251 }
252 
253 static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
254 {
255  TransContext *s = inlink->dst->priv;
256 
257  return s->passthrough ?
258  ff_null_get_video_buffer (inlink, w, h) :
259  ff_default_get_video_buffer(inlink, w, h);
260 }
261 
262 typedef struct ThreadData {
263  AVFrame *in, *out;
264 } ThreadData;
265 
266 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
267  int nb_jobs)
268 {
269  TransContext *s = ctx->priv;
270  ThreadData *td = arg;
271  AVFrame *out = td->out;
272  AVFrame *in = td->in;
273  int plane;
274 
275  for (plane = 0; out->data[plane]; plane++) {
276  int hsub = plane == 1 || plane == 2 ? s->hsub : 0;
277  int vsub = plane == 1 || plane == 2 ? s->vsub : 0;
278  int pixstep = s->pixsteps[plane];
279  int inh = AV_CEIL_RSHIFT(in->height, vsub);
280  int outw = AV_CEIL_RSHIFT(out->width, hsub);
281  int outh = AV_CEIL_RSHIFT(out->height, vsub);
282  int start = (outh * jobnr ) / nb_jobs;
283  int end = (outh * (jobnr+1)) / nb_jobs;
284  uint8_t *dst, *src;
285  int dstlinesize, srclinesize;
286  int x, y;
287 
288  dstlinesize = out->linesize[plane];
289  dst = out->data[plane] + start * dstlinesize;
290  src = in->data[plane];
291  srclinesize = in->linesize[plane];
292 
293  if (s->dir & 1) {
294  src += in->linesize[plane] * (inh - 1);
295  srclinesize *= -1;
296  }
297 
298  if (s->dir & 2) {
299  dst = out->data[plane] + dstlinesize * (outh - start - 1);
300  dstlinesize *= -1;
301  }
302 
303  for (y = start; y < end - 7; y += 8) {
304  for (x = 0; x < outw - 7; x += 8) {
305  s->transpose_8x8(src + x * srclinesize + y * pixstep,
306  srclinesize,
307  dst + (y - start) * dstlinesize + x * pixstep,
308  dstlinesize);
309  }
310  if (outw - x > 0 && end - y > 0)
311  s->transpose_block(src + x * srclinesize + y * pixstep,
312  srclinesize,
313  dst + (y - start) * dstlinesize + x * pixstep,
314  dstlinesize, outw - x, end - y);
315  }
316 
317  if (end - y > 0)
318  s->transpose_block(src + 0 * srclinesize + y * pixstep,
319  srclinesize,
320  dst + (y - start) * dstlinesize + 0 * pixstep,
321  dstlinesize, outw, end - y);
322  }
323 
324  return 0;
325 }
326 
327 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
328 {
329  AVFilterContext *ctx = inlink->dst;
330  TransContext *s = ctx->priv;
331  AVFilterLink *outlink = ctx->outputs[0];
332  ThreadData td;
333  AVFrame *out;
334 
335  if (s->passthrough)
336  return ff_filter_frame(outlink, in);
337 
338  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
339  if (!out) {
340  av_frame_free(&in);
341  return AVERROR(ENOMEM);
342  }
343  av_frame_copy_props(out, in);
344 
345  if (in->sample_aspect_ratio.num == 0) {
347  } else {
350  }
351 
352  td.in = in, td.out = out;
353  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
354  av_frame_free(&in);
355  return ff_filter_frame(outlink, out);
356 }
357 
358 #define OFFSET(x) offsetof(TransContext, x)
359 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
360 
361 static const AVOption transpose_options[] = {
362  { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
363  { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
364  { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .flags=FLAGS, .unit = "dir" },
365  { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .flags=FLAGS, .unit = "dir" },
366  { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
367 
368  { "passthrough", "do not apply transposition if the input matches the specified geometry",
369  OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE}, 0, INT_MAX, FLAGS, "passthrough" },
370  { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_NONE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
371  { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_PORTRAIT}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
372  { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_LANDSCAPE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
373 
374  { NULL }
375 };
376 
378 
380  {
381  .name = "default",
382  .type = AVMEDIA_TYPE_VIDEO,
383  .get_video_buffer = get_video_buffer,
384  .filter_frame = filter_frame,
385  },
386  { NULL }
387 };
388 
390  {
391  .name = "default",
392  .config_props = config_props_output,
393  .type = AVMEDIA_TYPE_VIDEO,
394  },
395  { NULL }
396 };
397 
399  .name = "transpose",
400  .description = NULL_IF_CONFIG_SMALL("Transpose input video."),
401  .priv_size = sizeof(TransContext),
402  .priv_class = &transpose_class,
404  .inputs = avfilter_vf_transpose_inputs,
405  .outputs = avfilter_vf_transpose_outputs,
407 };
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
int plane
Definition: avisynth_c.h:422
#define NULL
Definition: coverity.c:32
#define AV_RB48(x)
Definition: intreadwrite.h:477
const char * s
Definition: avisynth_c.h:768
AVFILTER_DEFINE_CLASS(transpose)
AVFrame * out
Definition: af_headphone.c:146
static void transpose_block_24_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:120
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2419
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
AVOption.
Definition: opt.h:246
static void transpose_8x8_24_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:133
static void transpose_8x8_32_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:150
const char * fmt
Definition: avisynth_c.h:769
static void transpose_8x8_16_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:114
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:60
TransposeDir
Definition: vf_transpose.c:47
int num
Numerator.
Definition: rational.h:59
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:39
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
#define src
Definition: vp8dsp.c:254
AVFilter ff_vf_transpose
Definition: vf_transpose.c:398
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
static const AVFilterPad avfilter_vf_transpose_outputs[]
Definition: vf_transpose.c:389
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:35
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1151
AVFrame * in
Definition: af_headphone.c:146
uint8_t
AVOptions.
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
#define AV_WB48(p, darg)
Definition: intreadwrite.h:486
static void transpose_block_48_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:156
static int flags
Definition: log.c:57
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
int width
Definition: frame.h:259
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
const char * arg
Definition: jacosubdec.c:66
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:337
int pixsteps[4]
Definition: vf_transpose.c:57
static void transpose_8x8_48_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:169
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
static void transpose_block_16_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:104
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:857
#define FFMIN(a, b)
Definition: common.h:96
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
int32_t
AVFormatContext * ctx
Definition: movenc.c:48
static void transpose_block_64_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:175
void(* transpose_block)(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:64
#define AV_WB24(p, d)
Definition: intreadwrite.h:455
static int query_formats(AVFilterContext *ctx)
Definition: vf_transpose.c:69
#define FLAGS
Definition: vf_transpose.c:359
PassthroughType
Definition: vf_transpose.c:41
static const AVOption transpose_options[]
Definition: vf_transpose.c:361
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:185
int passthrough
PassthroughType, landscape passthrough mode enabled.
Definition: vf_transpose.c:59
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static void transpose_block_8_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:88
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_transpose.c:253
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:87
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int dir
TransposeDir.
Definition: vf_transpose.c:60
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:289
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
Rational number (pair of numerator and denominator).
Definition: rational.h:58
const char * name
Filter name.
Definition: avfilter.h:148
GLsizei GLboolean transpose
Definition: opengl_enc.c:109
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
int den
Denominator.
Definition: rational.h:60
avfilter_execute_func * execute
Definition: internal.h:155
#define OFFSET(x)
Definition: vf_transpose.c:358
static const AVFilterPad avfilter_vf_transpose_inputs[]
Definition: vf_transpose.c:379
A list of supported formats for one end of a filter link.
Definition: formats.h:64
void(* transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:62
An instance of a filter.
Definition: avfilter.h:338
static void transpose_8x8_8_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:98
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_transpose.c:266
int height
Definition: frame.h:259
FILE * out
Definition: movenc.c:54
void INT64 start
Definition: avisynth_c.h:690
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_transpose.c:327
internal API functions
static int config_props_output(AVFilterLink *outlink)
Definition: vf_transpose.c:191
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:603
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
static void transpose_block_32_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:139