35 #define OFFSET(x) offsetof(TInterlaceContext, x)
36 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
37 #define TINTERLACE_FLAG_VLPF 01
38 #define TINTERLACE_FLAG_EXACT_TB 2
60 #define FULL_SCALE_YUVJ_FORMATS \
61 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
94 for (i = 0; i <
width; i++) {
98 dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
121 outlink->
w = inlink->
w;
123 inlink->
h*2 : inlink->
h;
129 uint8_t black[4] = { 16, 128, 128, 16 };
132 black[0] = black[3] = 0;
134 outlink->
w, outlink->
h, outlink->
format, 1);
139 for (i = 0; i < 4 && tinterlace->
black_data[i]; i++) {
157 }
else if (tinterlace->mode !=
MODE_PAD) {
163 if (!
av_cmp_q(standard_tbs[i], outlink->time_base))
168 outlink->time_base = tinterlace->preout_time_base;
178 inlink->h, outlink->h);
183 #define FIELD_UPPER 0
184 #define FIELD_LOWER 1
185 #define FIELD_UPPER_AND_LOWER 2
198 uint8_t *dst[4],
int dst_linesize[4],
211 int lines = plane == 1 || plane == 2 ?
FF_CEIL_RSHIFT(src_h, vsub) : src_h;
212 int cols = plane == 1 || plane == 2 ?
FF_CEIL_RSHIFT( w, hsub) : w;
218 srcp += src_linesize[
plane];
220 dstp += dst_linesize[
plane];
225 int srcp_linesize = src_linesize[
plane] * k;
226 int dstp_linesize = dst_linesize[
plane] * (interleave ? 2 : 1);
227 for (h = lines; h > 0; h--) {
230 if (h == lines) srcp_above =
srcp;
231 if (h == 1) srcp_below =
srcp;
233 tinterlace->
lowpass_line(dstp, cols, srcp, srcp_above, srcp_below);
234 dstp += dstp_linesize;
235 srcp += srcp_linesize;
239 srcp, src_linesize[plane]*k, cols, lines);
253 tinterlace->
cur = tinterlace->
next;
254 tinterlace->
next = picref;
256 cur = tinterlace->
cur;
257 next = tinterlace->
next;
259 if (!tinterlace->
cur)
262 switch (tinterlace->
mode) {
277 inlink->
format, inlink->
w, inlink->
h,
282 inlink->
format, inlink->
w, inlink->
h,
308 inlink->
format, inlink->
w, inlink->
h,
313 inlink->
format, inlink->
w, inlink->
h,
332 inlink->
format, inlink->
w, inlink->
h,
337 (
const uint8_t **)next->data, next->linesize,
338 inlink->
format, inlink->
w, inlink->
h,
339 tff ? FIELD_LOWER :
FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
357 tff = next->top_field_first;
366 out->
pts = cur->
pts + next->pts;
372 inlink->
format, inlink->
w, inlink->
h,
373 tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER,
377 (
const uint8_t **)next->data, next->linesize,
378 inlink->
format, inlink->
w, inlink->
h,
379 tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER,
412 .
name =
"tinterlace",
417 .
inputs = tinterlace_inputs,
419 .priv_class = &tinterlace_class,
static enum AVPixelFormat full_scale_yuvj_pix_fmts[]
static int query_formats(AVFilterContext *ctx)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
int h
agreed upon image height
int mode
TInterlaceMode, interlace mode selected.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_always_inline void interleave(IDWTELEM *dst, IDWTELEM *src0, IDWTELEM *src1, int w2, int add, int shift)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static AVRational av_make_q(int num, int den)
Create a rational.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int flags
flags affecting interlacing algorithm
AVFilter ff_vf_tinterlace
#define FULL_SCALE_YUVJ_FORMATS
BYTE int const BYTE * srcp
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const AVOption tinterlace_options[]
temporal field interlace filter, ported from MPlayer/libmpcodecs
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int frame
number of the output frame
static void lowpass_line_c(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, const uint8_t *srcp_above, const uint8_t *srcp_below)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
unsigned flags
Link processing flags.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void ff_tinterlace_init_x86(TInterlaceContext *interlace)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown; if left to 0/0, will be automatically be cop...
int vsub
chroma vertical subsampling
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
static void copy_picture_field(TInterlaceContext *tinterlace, uint8_t *dst[4], int dst_linesize[4], const uint8_t *src[4], int src_linesize[4], enum AVPixelFormat format, int w, int src_h, int src_field, int interleave, int dst_field, int flags)
Copy picture field from src to dst.
simple assert() macros that are a bit more flexible than ISO C assert().
AVFILTER_DEFINE_CLASS(tinterlace)
#define TINTERLACE_FLAG_EXACT_TB
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
uint8_t nb_components
The number of components each pixel has, (1-4)
static av_cold void uninit(AVFilterContext *ctx)
#define FF_CEIL_RSHIFT(a, b)
AVFilterContext * src
source filter
static const AVFilterPad tinterlace_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
Frame requests may need to loop in order to be fulfilled.
static const AVRational standard_tbs[]
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
uint8_t * black_data[4]
buffer used to fill padded lines
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
rational number numerator/denominator
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static const AVFilterPad tinterlace_inputs[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int config_out_props(AVFilterLink *outlink)
void(* lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, const uint8_t *srcp_above, const uint8_t *srcp_below)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
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-> out
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
#define FIELD_UPPER_AND_LOWER
AVRational preout_time_base
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define TINTERLACE_FLAG_VLPF
#define AV_NOPTS_VALUE
Undefined timestamp value.