mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-27 21:20:41 +00:00
lavfi: use ff_norm_qscale(), factorize
This commit is contained in:
parent
b23a866844
commit
57ede2a507
@ -40,7 +40,6 @@
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "internal.h"
|
||||
#include "libavcodec/avcodec.h" //for reference to FF_QSCALE_TYPE
|
||||
#include "vf_fspp.h"
|
||||
|
||||
#define OFFSET(x) offsetof(FSPPContext, x)
|
||||
@ -80,17 +79,6 @@ static const short custom_threshold[64] = {
|
||||
20, 27, 26, 23, 20, 15, 11, 5
|
||||
};
|
||||
|
||||
static inline int norm_qscale(int qscale, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case FF_QSCALE_TYPE_MPEG1: return qscale;
|
||||
case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
|
||||
case FF_QSCALE_TYPE_H264: return qscale >> 2;
|
||||
case FF_QSCALE_TYPE_VP56: return (63 - qscale + 2) >> 2;
|
||||
}
|
||||
return qscale;
|
||||
}
|
||||
|
||||
//This func reads from 1 slice, 1 and clears 0 & 1
|
||||
static void store_slice_c(uint8_t *dst, int16_t *src,
|
||||
ptrdiff_t dst_stride, ptrdiff_t src_stride,
|
||||
@ -218,7 +206,7 @@ static void filter(FSPPContext *p, uint8_t *dst, uint8_t *src,
|
||||
if (t < 0) t = 0; //t always < width-2
|
||||
|
||||
t = qp_store[qy + (t >> qpsh)];
|
||||
t = norm_qscale(t, p->qscale_type);
|
||||
t = ff_norm_qscale(t, p->qscale_type);
|
||||
|
||||
if (t != p->prev_q) p->prev_q = t, p->mul_thrmat((int16_t *)(&p->threshold_mtx_noq[0]), (int16_t *)(&p->threshold_mtx[0]), t);
|
||||
p->column_fidct((int16_t *)(&p->threshold_mtx[0]), block + x * 8, block3 + x * 8, 8); //yes, this is a HOTSPOT
|
||||
|
@ -229,18 +229,6 @@ static inline void add_block(uint16_t *dst, int linesize, const int16_t block[64
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: export the function?
|
||||
static inline int norm_qscale(int qscale, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case FF_QSCALE_TYPE_MPEG1: return qscale;
|
||||
case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
|
||||
case FF_QSCALE_TYPE_H264: return qscale >> 2;
|
||||
case FF_QSCALE_TYPE_VP56: return (63 - qscale + 2) >> 2;
|
||||
}
|
||||
return qscale;
|
||||
}
|
||||
|
||||
static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
|
||||
int dst_linesize, int src_linesize, int width, int height,
|
||||
const uint8_t *qp_table, int qp_stride, int is_luma, int depth)
|
||||
@ -284,7 +272,7 @@ static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
|
||||
} else{
|
||||
const int qps = 3 + is_luma;
|
||||
qp = qp_table[(FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
|
||||
qp = FFMAX(1, norm_qscale(qp, p->qscale_type));
|
||||
qp = FFMAX(1, ff_norm_qscale(qp, p->qscale_type));
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
const int x1 = x + offset[i + count - 1][0];
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "internal.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "avfilter.h"
|
||||
|
||||
#define MAX_LEVEL 8 /* quality levels */
|
||||
@ -181,18 +180,6 @@ static void store_slice_c(uint8_t *dst, const uint16_t *src,
|
||||
}
|
||||
}
|
||||
|
||||
static inline int norm_qscale(int qscale, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case FF_QSCALE_TYPE_MPEG1: return qscale;
|
||||
case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
|
||||
case FF_QSCALE_TYPE_H264: return qscale >> 2;
|
||||
case FF_QSCALE_TYPE_VP56: return (63 - qscale + 2) >> 2;
|
||||
default: av_assert0(0);
|
||||
}
|
||||
return qscale;
|
||||
}
|
||||
|
||||
static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
|
||||
int dst_stride[3], int src_stride[3], int width,
|
||||
int height, uint8_t *qp_store, int qp_stride)
|
||||
@ -237,7 +224,7 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
|
||||
for (x = 0; x < (width>>4); x++)
|
||||
qpsum += qp_store[x + y * qp_stride];
|
||||
}
|
||||
p->frame->quality = norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
|
||||
p->frame->quality = ff_norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
|
||||
}
|
||||
// init per MB qscale stuff FIXME
|
||||
p->frame->height = height;
|
||||
|
Loading…
Reference in New Issue
Block a user