FFmpeg  2.1.1
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/intreadwrite.h"
31 #include "libavutil/pixdesc.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/internal.h"
34 #include "libavutil/opt.h"
35 #include "avfilter.h"
36 #include "formats.h"
37 #include "internal.h"
38 #include "video.h"
39 
40 typedef enum {
45 
51 };
52 
53 typedef struct {
54  const AVClass *class;
55  int hsub, vsub;
56  int pixsteps[4];
57 
58  PassthroughType passthrough; ///< landscape passthrough mode enabled
59  enum TransposeDir dir;
60 } TransContext;
61 
63 {
64  AVFilterFormats *pix_fmts = NULL;
65  int fmt;
66 
67  for (fmt = 0; fmt < AV_PIX_FMT_NB; fmt++) {
68  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
69  if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
72  desc->log2_chroma_w != desc->log2_chroma_h))
73  ff_add_format(&pix_fmts, fmt);
74  }
75 
76 
77  ff_set_common_formats(ctx, pix_fmts);
78  return 0;
79 }
80 
81 static int config_props_output(AVFilterLink *outlink)
82 {
83  AVFilterContext *ctx = outlink->src;
84  TransContext *trans = ctx->priv;
85  AVFilterLink *inlink = ctx->inputs[0];
86  const AVPixFmtDescriptor *desc_out = av_pix_fmt_desc_get(outlink->format);
87  const AVPixFmtDescriptor *desc_in = av_pix_fmt_desc_get(inlink->format);
88 
89  if (trans->dir&4) {
91  "dir values greater than 3 are deprecated, use the passthrough option instead\n");
92  trans->dir &= 3;
94  }
95 
96  if ((inlink->w >= inlink->h && trans->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
97  (inlink->w <= inlink->h && trans->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
99  "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
100  inlink->w, inlink->h, inlink->w, inlink->h);
101  return 0;
102  } else {
104  }
105 
106  trans->hsub = desc_in->log2_chroma_w;
107  trans->vsub = desc_in->log2_chroma_h;
108 
109  av_image_fill_max_pixsteps(trans->pixsteps, NULL, desc_out);
110 
111  outlink->w = inlink->h;
112  outlink->h = inlink->w;
113 
114  if (inlink->sample_aspect_ratio.num){
115  outlink->sample_aspect_ratio = av_div_q((AVRational){1,1}, inlink->sample_aspect_ratio);
116  } else
117  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
118 
119  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
120  inlink->w, inlink->h, trans->dir, outlink->w, outlink->h,
121  trans->dir == 1 || trans->dir == 3 ? "clockwise" : "counterclockwise",
122  trans->dir == 0 || trans->dir == 3);
123  return 0;
124 }
125 
126 static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
127 {
128  TransContext *trans = inlink->dst->priv;
129 
130  return trans->passthrough ?
131  ff_null_get_video_buffer (inlink, w, h) :
132  ff_default_get_video_buffer(inlink, w, h);
133 }
134 
135 typedef struct ThreadData {
136  AVFrame *in, *out;
137 } ThreadData;
138 
139 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
140  int nb_jobs)
141 {
142  TransContext *trans = ctx->priv;
143  ThreadData *td = arg;
144  AVFrame *out = td->out;
145  AVFrame *in = td->in;
146  int plane;
147 
148  for (plane = 0; out->data[plane]; plane++) {
149  int hsub = plane == 1 || plane == 2 ? trans->hsub : 0;
150  int vsub = plane == 1 || plane == 2 ? trans->vsub : 0;
151  int pixstep = trans->pixsteps[plane];
152  int inh = in->height >> vsub;
153  int outw = FF_CEIL_RSHIFT(out->width, hsub);
154  int outh = FF_CEIL_RSHIFT(out->height, vsub);
155  int start = (outh * jobnr ) / nb_jobs;
156  int end = (outh * (jobnr+1)) / nb_jobs;
157  uint8_t *dst, *src;
158  int dstlinesize, srclinesize;
159  int x, y;
160 
161  dstlinesize = out->linesize[plane];
162  dst = out->data[plane] + start * dstlinesize;
163  src = in->data[plane];
164  srclinesize = in->linesize[plane];
165 
166  if (trans->dir&1) {
167  src += in->linesize[plane] * (inh-1);
168  srclinesize *= -1;
169  }
170 
171  if (trans->dir&2) {
172  dst = out->data[plane] + dstlinesize * (outh-start-1);
173  dstlinesize *= -1;
174  }
175 
176  switch (pixstep) {
177  case 1:
178  for (y = start; y < end; y++, dst += dstlinesize)
179  for (x = 0; x < outw; x++)
180  dst[x] = src[x*srclinesize + y];
181  break;
182  case 2:
183  for (y = start; y < end; y++, dst += dstlinesize) {
184  for (x = 0; x < outw; x++)
185  *((uint16_t *)(dst + 2*x)) = *((uint16_t *)(src + x*srclinesize + y*2));
186  }
187  break;
188  case 3:
189  for (y = start; y < end; y++, dst += dstlinesize) {
190  for (x = 0; x < outw; x++) {
191  int32_t v = AV_RB24(src + x*srclinesize + y*3);
192  AV_WB24(dst + 3*x, v);
193  }
194  }
195  break;
196  case 4:
197  for (y = start; y < end; y++, dst += dstlinesize) {
198  for (x = 0; x < outw; x++)
199  *((uint32_t *)(dst + 4*x)) = *((uint32_t *)(src + x*srclinesize + y*4));
200  }
201  break;
202  case 6:
203  for (y = start; y < end; y++, dst += dstlinesize) {
204  for (x = 0; x < outw; x++) {
205  int64_t v = AV_RB48(src + x*srclinesize + y*6);
206  AV_WB48(dst + 6*x, v);
207  }
208  }
209  break;
210  case 8:
211  for (y = start; y < end; y++, dst += dstlinesize) {
212  for (x = 0; x < outw; x++)
213  *((uint64_t *)(dst + 8*x)) = *((uint64_t *)(src + x*srclinesize + y*8));
214  }
215  break;
216  }
217  }
218 
219  return 0;
220 }
221 
222 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
223 {
224  AVFilterContext *ctx = inlink->dst;
225  TransContext *trans = ctx->priv;
226  AVFilterLink *outlink = ctx->outputs[0];
227  ThreadData td;
228  AVFrame *out;
229 
230  if (trans->passthrough)
231  return ff_filter_frame(outlink, in);
232 
233  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
234  if (!out) {
235  av_frame_free(&in);
236  return AVERROR(ENOMEM);
237  }
238  av_frame_copy_props(out, in);
239 
240  if (in->sample_aspect_ratio.num == 0) {
242  } else {
245  }
246 
247  td.in = in, td.out = out;
248  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ctx->graph->nb_threads));
249  av_frame_free(&in);
250  return ff_filter_frame(outlink, out);
251 }
252 
253 #define OFFSET(x) offsetof(TransContext, x)
254 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
255 
256 static const AVOption transpose_options[] = {
257  { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
258  { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .unit = "dir" },
259  { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .unit = "dir" },
260  { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .unit = "dir" },
261  { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .unit = "dir" },
262 
263  { "passthrough", "do not apply transposition if the input matches the specified geometry",
264  OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE}, 0, INT_MAX, FLAGS, "passthrough" },
265  { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_NONE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
266  { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_PORTRAIT}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
267  { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_LANDSCAPE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
268 
269  { NULL }
270 };
271 
273 
275  {
276  .name = "default",
277  .type = AVMEDIA_TYPE_VIDEO,
278  .get_video_buffer = get_video_buffer,
279  .filter_frame = filter_frame,
280  },
281  { NULL }
282 };
283 
285  {
286  .name = "default",
287  .config_props = config_props_output,
288  .type = AVMEDIA_TYPE_VIDEO,
289  },
290  { NULL }
291 };
292 
294  .name = "transpose",
295  .description = NULL_IF_CONFIG_SMALL("Transpose input video."),
296  .priv_size = sizeof(TransContext),
297  .priv_class = &transpose_class,
299  .inputs = avfilter_vf_transpose_inputs,
300  .outputs = avfilter_vf_transpose_outputs,
302 };
#define AV_WB24(p, d)
Definition: intreadwrite.h:442
float v
AVFrame * out
Definition: vf_hflip.c:79
This structure describes decoded (raw) audio or video data.
Definition: frame.h:96
AVOption.
Definition: opt.h:253
const char * name
Filter name.
Definition: avfilter.h:468
const char * fmt
Definition: avisynth_c.h:669
void * priv
private data for use by the filter
Definition: avfilter.h:648
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: avcodec.h:4153
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:111
TransposeDir
Definition: vf_transpose.c:46
int num
numerator
Definition: rational.h:44
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:35
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:109
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:68
static const AVFilterPad avfilter_vf_transpose_outputs[]
Definition: vf_transpose.c:284
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:32
const char * name
Pad name.
Definition: internal.h:66
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1118
AVFrame * in
Definition: vf_hflip.c:79
uint8_t
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only &quot;metadata&quot; fields from src to dst.
Definition: frame.c:446
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:67
enum TransposeDir dir
Definition: vf_transpose.c:59
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:98
#define FF_CEIL_RSHIFT(a, b)
Definition: avcodec.h:916
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:1194
#define AV_LOG_VERBOSE
Detailed information.
Definition: avcodec.h:4163
void 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:531
AVFilter avfilter_vf_transpose
Definition: vf_transpose.c:293
A filter pad used for either input or output.
Definition: internal.h:60
#define transpose(x)
int width
width and height of the video frame
Definition: frame.h:145
#define td
Definition: regdef.h:70
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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_dlog(ac->avr,"%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
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:77
#define AV_RB48(x)
Definition: intreadwrite.h:464
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:151
AVRational av_div_q(AVRational b, AVRational c) av_const
Divide one rational by another.
Definition: rational.c:87
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:436
const char * arg
Definition: jacosubdec.c:69
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:330
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:123
int pixsteps[4]
Definition: vf_transpose.c:56
common internal API header
float y
int32_t
#define FFMIN(a, b)
Definition: avcodec.h:925
static int query_formats(AVFilterContext *ctx)
Definition: vf_transpose.c:62
#define FLAGS
Definition: vf_transpose.c:254
PassthroughType
Definition: vf_transpose.c:40
static const AVOption transpose_options[]
Definition: vf_transpose.c:256
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1938
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:642
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:106
AVS_Value src
Definition: avisynth_c.h:523
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_transpose.c:126
uint8_t flags
Definition: pixdesc.h:78
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:57
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:177
Describe the class of an AVClass context structure.
Definition: log.h:50
Filter definition.
Definition: avfilter.h:464
#define AV_WB48(p, darg)
Definition: intreadwrite.h:473
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:102
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:635
rational number numerator/denominator
Definition: rational.h:43
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:124
#define AV_RB24(x)
Definition: intreadwrite.h:436
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
Definition: avcodec.h:4730
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:673
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:102
static int flags
Definition: cpu.c:45
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:43
PassthroughType passthrough
landscape passthrough mode enabled
Definition: vf_transpose.c:58
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:650
int den
denominator
Definition: rational.h:45
avfilter_execute_func * execute
Definition: internal.h:153
#define OFFSET(x)
Definition: vf_transpose.c:253
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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_dlog(ac->avr,"%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-> out
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:301
static const AVFilterPad avfilter_vf_transpose_inputs[]
Definition: vf_transpose.c:274
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define AVERROR(e)
An instance of a filter.
Definition: avfilter.h:627
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_transpose.c:139
int height
Definition: frame.h:145
void INT64 start
Definition: avisynth_c.h:594
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_transpose.c:222
internal API functions
static int config_props_output(AVFilterLink *outlink)
Definition: vf_transpose.c:81
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:107