47 #define OFFSET(x) offsetof(W3FDIFContext, x)
48 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
49 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
56 CONST(
"all",
"deinterlace all frames", 0,
"deint"),
57 CONST(
"interlaced",
"only deinterlace frames marked as interlaced", 1,
"deint"),
135 { -1704, 34472, 34472, -1704}};
138 { 2032, -7602, 11140, -7602, 2032}};
154 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
156 int32_t *work_line, *work_pixel;
165 const int start = (height * jobnr) / nb_jobs;
166 const int end = (height * (jobnr+1)) / nb_jobs;
167 int i, j, y_in, y_out;
172 in_line = cur_data + (y_out * cur_line_stride);
173 out_line = dst_data + (y_out * dst_line_stride);
175 while (y_out < end) {
176 memcpy(out_line, in_line, linesize);
178 in_line += cur_line_stride * 2;
179 out_line += dst_line_stride * 2;
185 out_line = dst_data + (y_out * dst_line_stride);
187 while (y_out < end) {
193 y_in = (y_out + 1) + (j * 2) - n_coef_lf[
filter];
197 while (y_in >= height)
200 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
204 switch (n_coef_lf[filter]) {
206 for (i = 0; i < linesize; i++) {
208 *work_line++ += *in_lines_cur[1]++ * coef_lf[
filter][1];
212 for (i = 0; i < linesize; i++) {
214 *work_line += *in_lines_cur[1]++ * coef_lf[
filter][1];
215 *work_line += *in_lines_cur[2]++ * coef_lf[
filter][2];
216 *work_line++ += *in_lines_cur[3]++ * coef_lf[
filter][3];
222 y_in = (y_out + 1) + (j * 2) - n_coef_hf[
filter];
226 while (y_in >= height)
229 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
230 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
234 switch (n_coef_hf[filter]) {
236 for (i = 0; i < linesize; i++) {
238 *work_line += *in_lines_adj[0]++ * coef_hf[
filter][0];
239 *work_line += *in_lines_cur[1]++ * coef_hf[
filter][1];
240 *work_line += *in_lines_adj[1]++ * coef_hf[
filter][1];
241 *work_line += *in_lines_cur[2]++ * coef_hf[
filter][2];
242 *work_line++ += *in_lines_adj[2]++ * coef_hf[
filter][2];
246 for (i = 0; i < linesize; i++) {
248 *work_line += *in_lines_adj[0]++ * coef_hf[
filter][0];
249 *work_line += *in_lines_cur[1]++ * coef_hf[
filter][1];
250 *work_line += *in_lines_adj[1]++ * coef_hf[
filter][1];
251 *work_line += *in_lines_cur[2]++ * coef_hf[
filter][2];
252 *work_line += *in_lines_adj[2]++ * coef_hf[
filter][2];
253 *work_line += *in_lines_cur[3]++ * coef_hf[
filter][3];
254 *work_line += *in_lines_adj[3]++ * coef_hf[
filter][3];
255 *work_line += *in_lines_cur[4]++ * coef_hf[
filter][4];
256 *work_line++ += *in_lines_adj[4]++ * coef_hf[
filter][4];
262 out_pixel = out_line;
264 for (j = 0; j < linesize; j++, out_pixel++, work_pixel++)
265 *out_pixel = av_clip(*work_pixel, 0, 255 * 256 * 256) >> 16;
269 out_line += dst_line_stride * 2;
293 int64_t cur_pts = s->
cur->
pts;
294 int64_t next_pts = s->
next->
pts;
297 out->
pts = cur_pts + next_pts;
305 for (plane = 0; plane < s->
nb_planes; plane++) {
373 }
else if (ret < 0) {
420 .priv_class = &w3fdif_class,
static int filter(AVFilterContext *ctx, int is_second)
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)
static const AVFilterPad outputs[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Main libavfilter public API header.
int h
agreed upon image height
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int is_disabled
the enabled state from the last expression evaluation
struct AVFilterGraph * graph
filtergraph this filter belongs to
const char * name
Pad name.
static const AVOption w3fdif_options[]
AVFilterLink ** inputs
array of pointers to input links
static int config_input(AVFilterLink *inlink)
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 int32_t coef_lf[2][4]
AVFILTER_DEFINE_CLASS(w3fdif)
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
int nb_threads
Maximum number of threads used by filters in this graph.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AVERROR_EOF
End of file.
int interlaced_frame
The content of the picture is interlaced.
A filter pad used for either input or output.
int linesize[4]
bytes of pixel data per line for each plane
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AVFrame * next
previous, current, next frames
static int query_formats(AVFilterContext *ctx)
unsigned flags
Link processing flags.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
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...
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
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int planeheight[4]
height of each plane
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
int field
which field are we on, 0 or 1
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_CEIL_RSHIFT(a, b)
AVFilterContext * src
source filter
static const int8_t n_coef_hf[2]
Frame requests may need to loop in order to be fulfilled.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
agreed upon media format
static int config_output(AVFilterLink *outlink)
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...
static const int8_t n_coef_lf[2]
BYTE int const BYTE int int int height
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
static const AVFilterPad inputs[]
const char * name
Filter name.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
AVFilterLink ** outputs
array of pointers to output links
static const int32_t coef_hf[2][5]
static enum AVPixelFormat pix_fmts[]
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define CONST(name, help, val, unit)
static const AVFilterPad w3fdif_inputs[]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
planar GBRA 4:4:4:4 32bpp
int deint
which frames to deinterlace
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
avfilter_execute_func * execute
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
static const AVFilterPad w3fdif_outputs[]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
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
static av_cold void uninit(AVFilterContext *ctx)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
int32_t ** work_line
lines we are calculating
static int request_frame(AVFilterLink *outlink)
AVPixelFormat
Pixel format.
int filter
0 is simple, 1 is more complex
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.