43 #define OFFSET(x) offsetof(PP7Context, x)
44 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
57 { 0, 48, 12, 60, 3, 51, 15, 63, },
58 { 32, 16, 44, 28, 35, 19, 47, 31, },
59 { 8, 56, 4, 52, 11, 59, 7, 55, },
60 { 40, 24, 36, 20, 43, 27, 39, 23, },
61 { 2, 50, 14, 62, 1, 49, 13, 61, },
62 { 34, 18, 46, 30, 33, 17, 45, 29, },
63 { 10, 58, 6, 54, 9, 57, 5, 53, },
64 { 42, 26, 38, 22, 41, 25, 37, 21, },
71 #define SN1 2.2360679775
72 #define SN2 3.16227766017
77 N / (N1 *
N0),
N / (N1 * N1),
N / (N1 *
N0),
N / (N1 * N2),
79 N / (N2 *
N0),
N / (N2 * N1),
N / (N2 *
N0),
N / (N2 * N2),
84 N / (SN2 *
SN0),
N / (SN2 * SN2),
N / (SN2 *
SN0),
N / (SN2 * SN2),
86 N / (SN2 *
SN0),
N / (SN2 * SN2),
N / (SN2 *
SN0),
N / (SN2 * SN2),
94 for (qp = 0; qp < 99; qp++) {
95 for (i = 0; i < 16; i++) {
105 for (i = 0; i < 4; i++) {
117 dst[1] = 2 * s3 +
s2;
118 dst[3] = s3 - 2 *
s2;
128 for (i = 0; i < 4; i++) {
129 int s0 = src[0 * 4] + src[6 * 4];
130 int s1 = src[1 * 4] + src[5 * 4];
131 int s2 = src[2 * 4] + src[4 * 4];
140 dst[1 * 4] = 2 * s3 +
s2;
141 dst[3 * 4] = s3 - 2 *
s2;
153 for (i = 1; i < 16; i++) {
154 unsigned int threshold1 = p->
thres2[qp][i];
155 unsigned int threshold2 = threshold1 << 1;
157 if (((
unsigned)(level + threshold1)) > threshold2)
158 a += level * factor[i];
160 return (a + (1 << 11)) >> 12;
169 for (i = 1; i < 16; i++) {
170 unsigned int threshold1 = p->
thres2[qp][i];
171 unsigned int threshold2 = threshold1 << 1;
173 if (((
unsigned)(level + threshold1)) > threshold2) {
174 if (((
unsigned)(level + 2 * threshold1)) > 2 * threshold2)
175 a += level * factor[i];
178 a += 2 * (level - (int)threshold1) * factor[i];
180 a += 2 * (level + (int)threshold1) * factor[i];
184 return (a + (1 << 11)) >> 12;
193 for (i = 1; i < 16; i++) {
194 unsigned int threshold1 = p->
thres2[qp][i];
195 unsigned int threshold2 = threshold1 << 1;
197 if (((
unsigned)(level + threshold1)) > threshold2) {
199 a += (level - (int)threshold1) * factor[i];
201 a += (level + (int)threshold1) * factor[i];
204 return (a + (1 << 11)) >> 12;
208 int dst_stride,
int src_stride,
210 uint8_t *qp_store,
int qp_stride,
int is_luma)
216 int16_t *
temp = (int16_t *)(p->
src + 32);
218 if (!src || !dst)
return;
219 for (y = 0; y <
height; y++) {
221 memcpy(p_src + index, src + y * src_stride, width);
222 for (x = 0; x < 8; x++) {
223 p_src[index - x - 1]= p_src[index + x ];
224 p_src[index + width + x ]= p_src[index + width - x - 1];
227 for (y = 0; y < 8; y++) {
228 memcpy(p_src + ( 7 - y ) * stride, p_src + ( y + 8 ) * stride, stride);
229 memcpy(p_src + (height + 8 + y) * stride, p_src + (height - y + 7) * stride, stride);
233 for (y = 0; y <
height; y++) {
234 for (x = -8; x < 0; x += 4) {
235 const int index = x + y * stride + (8 - 3) * (1 + stride) + 8;
237 int16_t *tp =
temp + 4 * x;
239 dctA_c(tp + 4 * 8, src, stride);
241 for (x = 0; x <
width; ) {
242 const int qps = 3 + is_luma;
249 qp = qp_store[ (
FFMIN(x, width - 1) >> qps) + (
FFMIN(y, height - 1) >> qps) * qp_stride];
252 for (; x <
end; x++) {
253 const int index = x + y * stride + (8 - 3) * (1 + stride) + 8;
255 int16_t *tp =
temp + 4 * x;
259 dctA_c(tp + 4 * 8, src, stride);
264 v = (v +
dither[y & 7][x & 7]) >> 6;
265 if ((
unsigned)v > 255)
267 dst[x + y * dst_stride] =
v;
292 const int h =
FFALIGN(inlink->
h + 16, 16);
341 const int aligned_w =
FFALIGN(inlink->
w, 8);
342 const int aligned_h =
FFALIGN(inlink->
h, 8);
354 if (qp_table || pp7->
qp) {
357 inlink->
w, inlink->
h, qp_table, qp_stride, 1);
359 cw, ch, qp_table, qp_stride, 0);
361 cw, ch, qp_table, qp_stride, 0);
370 inlink->
w, inlink->
h);
408 .priv_class = &pp7_class,
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 h
agreed upon image height
AVFILTER_DEFINE_CLASS(pp7)
#define DECLARE_ALIGNED(n, t, v)
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_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
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int8_t * av_frame_get_qp_table(AVFrame *f, int *stride, int *type)
int is_disabled
the enabled state from the last expression evaluation
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int query_formats(AVFilterContext *ctx)
static av_cold int end(AVCodecContext *avctx)
static const AVOption pp7_options[]
static int softthresh_c(PP7Context *p, int16_t *src, int qp)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
A filter pad used for either input or output.
A link between two filters.
static av_cold void uninit(AVFilterContext *ctx)
int width
width and height of the video frame
static void init_thres2(PP7Context *p)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void(* dctB)(int16_t *dst, int16_t *src)
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
static void dctB_c(int16_t *dst, int16_t *src)
simple assert() macros that are a bit more flexible than ISO C assert().
int(* requantize)(struct PP7Context *p, int16_t *src, int qp)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static int hardthresh_c(PP7Context *p, int16_t *src, int qp)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
#define FF_CEIL_RSHIFT(a, b)
static const AVFilterPad pp7_outputs[]
static void filter(PP7Context *p, uint8_t *dst, uint8_t *src, int dst_stride, int src_stride, int width, int height, uint8_t *qp_store, int qp_stride, int is_luma)
int format
agreed upon media format
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int mediumthresh_c(PP7Context *p, int16_t *src, int qp)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
BYTE int const BYTE int int int height
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
void ff_pp7_init_x86(PP7Context *pp7)
static const int factor[16]
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 int ff_norm_qscale(int qscale, int type)
Normalize the qscale factor FIXME the H264 qscale is a log based scale, mpeg1/2 is not...
static const uint8_t dither[8][8]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void dctA_c(int16_t *dst, uint8_t *src, int stride)
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_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
static const AVFilterPad pp7_inputs[]
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVFilterContext * dst
dest filter
static const int thres[16]
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
#define av_malloc_array(a, b)
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.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int config_input(AVFilterLink *inlink)