History

avcodec/libdav1d: parse DV profile 10 T.35 OBU

This is thankfully passed through verbatim by libdav1d, so we can parse it in our own code. In theory, taking the DV profile from the packet-level configuration struct is redundant since there is currently only one possible DV level for AV1 (and all others would fail parsing), but this marginally future-proofs it against possible new AV1-specific profiles being added in the future.

Niklas Haas committed 2 years ago

Commit a5d1e691 parent 9aecd711 file · +25 −0Browse files

Unified · Split

libavcodec/libdav1d.c+25−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "bytestream.h"
3636 #include "codec_internal.h"
3737 #include "decode.h"
38+#include "dovi_rpu.h"
3839 #include "internal.h"
3940
4041 #define FF_DAV1D_VERSION_AT_LEAST(x,y) \
@@ -44,6 +45,7 @@ typedef struct Libdav1dContext { · 3 unmodified lines
4445 AVClass *class;
4546 Dav1dContext *c;
4647 AVBufferPool *pool;
48+ DOVIContext dovi;
4749 int pool_size;
4850
4951 Dav1dData data;
@@ -213,6 +215,7 @@ static av_cold int libdav1d_init(AVCodecContext *c) · 163 unmodified lines
213215 #else
214216 int threads = (c->thread_count ? c->thread_count : av_cpu_count()) * 3 / 2;
215217 #endif
218+ const AVPacketSideData *sd;
216219 int res;
217220
218221 av_log(c, AV_LOG_VERBOSE, "libdav1d %s\n", dav1d_version());
@@ -285,6 +288,11 @@ static av_cold int libdav1d_init(AVCodecContext *c) · 66 unmodified lines
285288 c->delay = res > 1 ? res : 0;
286289 #endif
287290
291+ dav1d->dovi.logctx = c;
292+ dav1d->dovi.dv_profile = 10; // default for AV1
293+ sd = ff_get_coded_side_data(c, AV_PKT_DATA_DOVI_CONF);
294+ if (sd && sd->size > 0)
295+ ff_dovi_update_cfg(&dav1d->dovi, (AVDOVIDecoderConfigurationRecord *) sd->data);
288296 return 0;
289297 }
290298
@@ -579,6 +587,22 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) · 288 unmodified lines
579587 goto fail;
580588 break;
581589 }
590+ case 0x3B: { // dolby_provider_code
591+ int provider_oriented_code = bytestream2_get_be32(&gb);
592+ if (itut_t35->country_code != 0xB5 || provider_oriented_code != 0x800)
593+ break;
594+
595+ res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, gb.buffer_end - gb.buffer);
596+ if (res < 0) {
597+ av_log(c, AV_LOG_WARNING, "Error parsing DOVI OBU.\n");
598+ break; // ignore
599+ }
600+
601+ res = ff_dovi_attach_side_data(&dav1d->dovi, frame);
602+ if (res < 0)
603+ goto fail;
604+ break;
605+ }
582606 default: // ignore unsupported provider codes
583607 break;
584608 }
@@ -638,6 +662,7 @@ static av_cold int libdav1d_close(AVCodecContext *c) · 53 unmodified lines
638662 Libdav1dContext *dav1d = c->priv_data;
639663
640664 av_buffer_pool_uninit(&dav1d->pool);
665+ ff_dovi_ctx_unref(&dav1d->dovi);
641666 dav1d_data_unref(&dav1d->data);
642667 dav1d_close(&dav1d->c);
643668

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