Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictorien Le Couviour--Tuffet <victorien@videolan.org>2022-02-01 19:44:26 +0300
committerVictorien Le Couviour--Tuffet <victorien@videolan.org>2022-02-28 20:20:48 +0300
commit402b54fcaecd424726b3f1292b4fea3c5b1d8e35 (patch)
tree49528575fc5ca345346f7e84974ecd19e9844afc /src/fg_apply_tmpl.c
parentb010080fea75435327fc90824bb4d8035722b3cb (diff)
Integrate film grain in the task threading system
Diffstat (limited to 'src/fg_apply_tmpl.c')
-rw-r--r--src/fg_apply_tmpl.c109
1 files changed, 65 insertions, 44 deletions
diff --git a/src/fg_apply_tmpl.c b/src/fg_apply_tmpl.c
index c254a3d..1ffc6e0 100644
--- a/src/fg_apply_tmpl.c
+++ b/src/fg_apply_tmpl.c
@@ -89,14 +89,13 @@ static void generate_scaling(const int bitdepth,
}
#ifndef UNIT_TEST
-void bitfn(dav1d_apply_grain)(const Dav1dFilmGrainDSPContext *const dsp,
- Dav1dPicture *const out,
- const Dav1dPicture *const in)
+void bitfn(dav1d_prep_grain)(const Dav1dFilmGrainDSPContext *const dsp,
+ Dav1dPicture *const out,
+ const Dav1dPicture *const in,
+ uint8_t scaling[3][SCALING_SIZE],
+ entry grain_lut[3][GRAIN_HEIGHT+1][GRAIN_WIDTH])
{
const Dav1dFilmGrainData *const data = &out->frame_hdr->film_grain.data;
-
- ALIGN_STK_16(entry, grain_lut, 3,[GRAIN_HEIGHT + 1][GRAIN_WIDTH]);
- uint8_t scaling[3][SCALING_SIZE];
#if BITDEPTH != 8
const int bitdepth_max = (1 << out->p.bpc) - 1;
#endif
@@ -150,60 +149,82 @@ void bitfn(dav1d_apply_grain)(const Dav1dFilmGrainDSPContext *const dsp,
memcpy(out->data[2], in->data[2], sz);
}
}
+}
+void bitfn(dav1d_apply_grain_row)(const Dav1dFilmGrainDSPContext *const dsp,
+ Dav1dPicture *const out,
+ const Dav1dPicture *const in,
+ const uint8_t scaling[3][SCALING_SIZE],
+ const entry grain_lut[3][GRAIN_HEIGHT+1][GRAIN_WIDTH],
+ const int row)
+{
// Synthesize grain for the affected planes
- const int rows = (out->p.h + 31) >> 5;
+ const Dav1dFilmGrainData *const data = &out->frame_hdr->film_grain.data;
const int ss_y = in->p.layout == DAV1D_PIXEL_LAYOUT_I420;
const int ss_x = in->p.layout != DAV1D_PIXEL_LAYOUT_I444;
const int cpw = (out->p.w + ss_x) >> ss_x;
const int is_id = out->seq_hdr->mtrx == DAV1D_MC_IDENTITY;
- for (int row = 0; row < rows; row++) {
- pixel *const luma_src =
- ((pixel *) in->data[0]) + row * BLOCK_SIZE * PXSTRIDE(in->stride[0]);
-
- if (data->num_y_points) {
- const int bh = imin(out->p.h - row * BLOCK_SIZE, BLOCK_SIZE);
- dsp->fgy_32x32xn(((pixel *) out->data[0]) + row * BLOCK_SIZE * PXSTRIDE(out->stride[0]),
- luma_src, out->stride[0], data,
- out->p.w, scaling[0], grain_lut[0], bh, row HIGHBD_TAIL_SUFFIX);
- }
+ pixel *const luma_src =
+ ((pixel *) in->data[0]) + row * BLOCK_SIZE * PXSTRIDE(in->stride[0]);
+#if BITDEPTH != 8
+ const int bitdepth_max = (1 << out->p.bpc) - 1;
+#endif
- if (!data->num_uv_points[0] && !data->num_uv_points[1] &&
- !data->chroma_scaling_from_luma)
- {
- continue;
- }
+ if (data->num_y_points) {
+ const int bh = imin(out->p.h - row * BLOCK_SIZE, BLOCK_SIZE);
+ dsp->fgy_32x32xn(((pixel *) out->data[0]) + row * BLOCK_SIZE * PXSTRIDE(out->stride[0]),
+ luma_src, out->stride[0], data,
+ out->p.w, scaling[0], grain_lut[0], bh, row HIGHBD_TAIL_SUFFIX);
+ }
- const int bh = (imin(out->p.h - row * BLOCK_SIZE, BLOCK_SIZE) + ss_y) >> ss_y;
+ if (!data->num_uv_points[0] && !data->num_uv_points[1] &&
+ !data->chroma_scaling_from_luma)
+ {
+ return;
+ }
- // extend padding pixels
- if (out->p.w & ss_x) {
- pixel *ptr = luma_src;
- for (int y = 0; y < bh; y++) {
- ptr[out->p.w] = ptr[out->p.w - 1];
- ptr += PXSTRIDE(in->stride[0]) << ss_y;
- }
+ const int bh = (imin(out->p.h - row * BLOCK_SIZE, BLOCK_SIZE) + ss_y) >> ss_y;
+
+ // extend padding pixels
+ if (out->p.w & ss_x) {
+ pixel *ptr = luma_src;
+ for (int y = 0; y < bh; y++) {
+ ptr[out->p.w] = ptr[out->p.w - 1];
+ ptr += PXSTRIDE(in->stride[0]) << ss_y;
}
+ }
- const ptrdiff_t uv_off = row * BLOCK_SIZE * PXSTRIDE(out->stride[1]) >> ss_y;
- if (data->chroma_scaling_from_luma) {
- for (int pl = 0; pl < 2; pl++)
+ const ptrdiff_t uv_off = row * BLOCK_SIZE * PXSTRIDE(out->stride[1]) >> ss_y;
+ if (data->chroma_scaling_from_luma) {
+ for (int pl = 0; pl < 2; pl++)
+ dsp->fguv_32x32xn[in->p.layout - 1](((pixel *) out->data[1 + pl]) + uv_off,
+ ((const pixel *) in->data[1 + pl]) + uv_off,
+ in->stride[1], data, cpw,
+ scaling[0], grain_lut[1 + pl],
+ bh, row, luma_src, in->stride[0],
+ pl, is_id HIGHBD_TAIL_SUFFIX);
+ } else {
+ for (int pl = 0; pl < 2; pl++)
+ if (data->num_uv_points[pl])
dsp->fguv_32x32xn[in->p.layout - 1](((pixel *) out->data[1 + pl]) + uv_off,
((const pixel *) in->data[1 + pl]) + uv_off,
in->stride[1], data, cpw,
- scaling[0], grain_lut[1 + pl],
+ scaling[1 + pl], grain_lut[1 + pl],
bh, row, luma_src, in->stride[0],
pl, is_id HIGHBD_TAIL_SUFFIX);
- } else {
- for (int pl = 0; pl < 2; pl++)
- if (data->num_uv_points[pl])
- dsp->fguv_32x32xn[in->p.layout - 1](((pixel *) out->data[1 + pl]) + uv_off,
- ((const pixel *) in->data[1 + pl]) + uv_off,
- in->stride[1], data, cpw,
- scaling[1 + pl], grain_lut[1 + pl],
- bh, row, luma_src, in->stride[0],
- pl, is_id HIGHBD_TAIL_SUFFIX);
- }
}
}
+
+void bitfn(dav1d_apply_grain)(const Dav1dFilmGrainDSPContext *const dsp,
+ Dav1dPicture *const out,
+ const Dav1dPicture *const in)
+{
+ ALIGN_STK_16(entry, grain_lut, 3,[GRAIN_HEIGHT + 1][GRAIN_WIDTH]);
+ uint8_t scaling[3][SCALING_SIZE];
+ const int rows = (out->p.h + 31) >> 5;
+
+ bitfn(dav1d_prep_grain)(dsp, out, in, scaling, grain_lut);
+ for (int row = 0; row < rows; row++)
+ bitfn(dav1d_apply_grain_row)(dsp, out, in, scaling, grain_lut, row);
+}
#endif