History

avcodec/mpegvideo: Move noise_reduction to MPVMainEncContext

Andreas Rheinhardt committed 1 year ago

Commit 1b537de1 parent f2ba0673 files · +14 −11Browse files

Showing the changes to libavcodec (3 of 3 files). Show all

Unified · Split

3 files
  1. libavcodec/mpegvideo.h +0 −2
  2. libavcodec/mpegvideo_enc.c +11 −8
  3. libavcodec/mpegvideoenc.h +3 −1
libavcodec/mpegvideo.h+0−2
@@ -473,8 +473,6 @@ typedef struct MpegEncContext { · 472 unmodified lines
473473
474474 int error_rate;
475475
476− int noise_reduction;
477−
478476 int intra_penalty;
479477 } MpegEncContext;
480478
libavcodec/mpegvideo_enc.c+11−8
@@ -442,7 +442,7 @@ static av_cold int init_buffers(MPVMainEncContext *const m, AVCodecContext *avct · 441 unmodified lines
442442 int has_b_frames = !!m->max_b_frames, nb_mv_tables = 1 + 5 * has_b_frames;
443443 int16_t (*mv_table)[2];
444444
445− if (s->noise_reduction) {
445+ if (m->noise_reduction) {
446446 if (!FF_ALLOCZ_TYPED_ARRAY(s->dct_offset, 2))
447447 return AVERROR(ENOMEM);
448448 dct_error = av_mallocz(ALIGN - 1 + nb_slices * DCT_ERROR_SIZE);
@@ -1877,8 +1877,9 @@ static void frame_end(MPVMainEncContext *const m) · 1428 unmodified lines
18771877 s->last_non_b_pict_type = s->pict_type;
18781878 }
18791879
1880−static void update_noise_reduction(MpegEncContext *s)
1880+static void update_noise_reduction(MPVMainEncContext *const m)
18811881 {
1882+ MpegEncContext *const s = &m->s;
18821883 int intra, i;
18831884
18841885 for (intra = 0; intra < 2; intra++) {
@@ -1890,7 +1891,7 @@ static void update_noise_reduction(MpegEncContext *s) · 5 unmodified lines
18901891 }
18911892
18921893 for (i = 0; i < 64; i++) {
1893− s->dct_offset[intra][i] = (s->noise_reduction *
1894+ s->dct_offset[intra][i] = (m->noise_reduction *
18941895 s->dct_count[intra] +
18951896 s->dct_error_sum[intra][i] / 2) /
18961897 (s->dct_error_sum[intra][i] + 1);
@@ -1898,8 +1899,10 @@ static void update_noise_reduction(MpegEncContext *s) · 1 unmodified line
18981899 }
18991900 }
19001901
1901−static void frame_start(MpegEncContext *s)
1902+static void frame_start(MPVMainEncContext *const m)
19021903 {
1904+ MpegEncContext *const s = &m->s;
1905+
19031906 s->cur_pic.ptr->f->pict_type = s->pict_type;
19041907
19051908 if (s->pict_type != AV_PICTURE_TYPE_B) {
@@ -1907,9 +1910,9 @@ static void frame_start(MpegEncContext *s) · 1 unmodified line
19071910 ff_mpv_replace_picture(&s->next_pic, &s->cur_pic);
19081911 }
19091912
1913+ av_assert2(!!m->noise_reduction == !!s->dct_error_sum);
19101914 if (s->dct_error_sum) {
1911− av_assert2(s->noise_reduction && s->encoding);
1912− update_noise_reduction(s);
1915+ update_noise_reduction(m);
19131916 }
19141917 }
19151918
@@ -1959,7 +1962,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, · 43 unmodified lines
19591962
19601963 s->pict_type = s->new_pic->pict_type;
19611964 //emms_c();
1962− frame_start(s);
1965+ frame_start(m);
19631966 vbv_retry:
19641967 ret = encode_picture(m, pkt);
19651968 if (growing_buffer) {
@@ -3598,7 +3601,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) · 1632 unmodified lines
35983601 MERGE(encoding_error[1]);
35993602 MERGE(encoding_error[2]);
36003603
3601− if (dst->noise_reduction){
3604+ if (dst->dct_error_sum) {
36023605 for(i=0; i<64; i++){
36033606 MERGE(dct_error_sum[0][i]);
36043607 MERGE(dct_error_sum[1][i]);
libavcodec/mpegvideoenc.h+3−1
@@ -68,6 +68,8 @@ typedef struct MPVMainEncContext { · 67 unmodified lines
6868
6969 int scenechange_threshold;
7070
71+ int noise_reduction;
72+
7173 float border_masking;
7274 int lmin, lmax;
7375 int vbv_ignore_qmax;
@@ -199,7 +201,7 @@ FF_MPV_OPT_CMP_FUNC, \ · 125 unmodified lines
199201 {"skip_factor", "Frame skip factor", FF_MPV_MAIN_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
200202 {"skip_exp", "Frame skip exponent", FF_MPV_MAIN_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
201203 {"skip_cmp", "Frame skip compare function", FF_MPV_MAIN_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, .unit = "cmp_func" }, \
202−{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
204+{"noise_reduction", "Noise reduction", FF_MPV_MAIN_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
203205 {"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
204206
205207 #define FF_MPV_COMMON_BFRAME_OPTS \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t