I restricted this SEI to HEVC for now, until I see a H.264 sample.
Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -105,7 +105,7 @@ OBJS-$(CONFIG_H264_SEI) += h264_sei.o h2645_sei.o · 104 unmodified lines | ||
| 105 | 105 | OBJS-$(CONFIG_HEVCPARSE) += hevc_parse.o hevc_ps.o hevc_data.o \ |
| 106 | 106 | h2645data.o h2645_parse.o h2645_vui.o |
| 107 | 107 | OBJS-$(CONFIG_HEVC_SEI) += hevc_sei.o h2645_sei.o \ |
| 108 | − dynamic_hdr_vivid.o | |
| 108 | + dynamic_hdr_vivid.o aom_film_grain.o | |
| 109 | 109 | OBJS-$(CONFIG_HPELDSP) += hpeldsp.o |
| 110 | 110 | OBJS-$(CONFIG_HUFFMAN) += huffman.o |
| 111 | 111 | OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o |
| @@ -211,6 +211,24 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, · 210 unmodified lines | ||
| 211 | 211 | } |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | + case 0x5890: { // aom_provider_code | |
| 215 | + const uint16_t aom_grain_provider_oriented_code = 0x0001; | |
| 216 | + uint16_t provider_oriented_code; | |
| 217 | + | |
| 218 | + if (!IS_HEVC(codec_id)) | |
| 219 | + goto unsupported_provider_code; | |
| 220 | + | |
| 221 | + if (bytestream2_get_bytes_left(gb) < 2) | |
| 222 | + return AVERROR_INVALIDDATA; | |
| 223 | + | |
| 224 | + provider_oriented_code = bytestream2_get_byteu(gb); | |
| 225 | + if (provider_oriented_code == aom_grain_provider_oriented_code) { | |
| 226 | + return ff_aom_parse_film_grain_sets(&h->aom_film_grain, | |
| 227 | + gb->buffer, | |
| 228 | + bytestream2_get_bytes_left(gb)); | |
| 229 | + } | |
| 230 | + break; | |
| 231 | + } | |
| 214 | 232 | unsupported_provider_code: |
| 215 | 233 | #endif |
| 216 | 234 | default: |
| @@ -704,6 +722,12 @@ FF_ENABLE_DEPRECATION_WARNINGS · 487 unmodified lines | ||
| 704 | 722 | avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; |
| 705 | 723 | } |
| 706 | 724 | |
| 725 | +#if CONFIG_HEVC_SEI | |
| 726 | + ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame); | |
| 727 | + if (ret < 0) | |
| 728 | + return ret; | |
| 729 | +#endif | |
| 730 | + | |
| 707 | 731 | if (sei->ambient_viewing_environment.present) { |
| 708 | 732 | H2645SEIAmbientViewingEnvironment *env = |
| 709 | 733 | &sei->ambient_viewing_environment; |
| @@ -800,4 +824,5 @@ void ff_h2645_sei_reset(H2645SEI *s) · 90 unmodified lines | ||
| 800 | 824 | s->ambient_viewing_environment.present = 0; |
| 801 | 825 | s->mastering_display.present = 0; |
| 802 | 826 | s->content_light.present = 0; |
| 827 | + s->aom_film_grain.enable = 0; | |
| 803 | 828 | } |
| @@ -23,7 +23,9 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include "libavutil/buffer.h" |
| 25 | 25 | #include "libavutil/frame.h" |
| 26 | +#include "libavutil/film_grain_params.h" | |
| 26 | 27 | |
| 28 | +#include "aom_film_grain.h" | |
| 27 | 29 | #include "avcodec.h" |
| 28 | 30 | #include "bytestream.h" |
| 29 | 31 | #include "codec_id.h" |
| @@ -132,6 +134,7 @@ typedef struct H2645SEI { · 102 unmodified lines | ||
| 132 | 134 | H2645SEIAmbientViewingEnvironment ambient_viewing_environment; |
| 133 | 135 | H2645SEIMasteringDisplay mastering_display; |
| 134 | 136 | H2645SEIContentLight content_light; |
| 137 | + AVFilmGrainAFGS1Params aom_film_grain; | |
| 135 | 138 | } H2645SEI; |
| 136 | 139 | |
| 137 | 140 | enum { |