MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av1_decode_init

Function av1_decode_init

libavcodec/av1dec.c:861–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859};
860
861static av_cold int av1_decode_init(AVCodecContext *avctx)
862{
863 AV1DecContext *s = avctx->priv_data;
864 AV1RawSequenceHeader *seq;
865 const AVPacketSideData *sd;
866 int ret;
867
868 s->avctx = avctx;
869 s->pkt = avctx->internal->in_pkt;
870 s->pix_fmt = AV_PIX_FMT_NONE;
871
872 ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_AV1, avctx);
873 if (ret < 0)
874 return ret;
875
876 s->cbc->decompose_unit_types = decompose_unit_types;
877 s->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
878
879 s->itut_t35_fifo = av_fifo_alloc2(1, sizeof(AV1RawMetadataITUTT35),
880 AV_FIFO_FLAG_AUTO_GROW);
881 if (!s->itut_t35_fifo)
882 return AVERROR(ENOMEM);
883
884 av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 0);
885
886 if (avctx->extradata && avctx->extradata_size) {
887 ret = ff_cbs_read_extradata_from_codec(s->cbc,
888 &s->current_obu,
889 avctx);
890 if (ret < 0) {
891 av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
892 goto end;
893 }
894
895 seq = ((CodedBitstreamAV1Context *)(s->cbc->priv_data))->sequence_header;
896 if (!seq) {
897 if (!(avctx->extradata[0] & 0x80))
898 av_log(avctx, AV_LOG_WARNING, "No sequence header available in extradata.\n");
899 goto end;
900 }
901
902 ret = set_context_with_sequence(avctx, seq);
903 if (ret < 0) {
904 av_log(avctx, AV_LOG_WARNING, "Failed to set decoder context.\n");
905 goto end;
906 }
907
908 end:
909 ff_cbs_fragment_reset(&s->current_obu);
910 }
911
912 s->dovi.logctx = avctx;
913 s->dovi.cfg.dv_profile = 10; // default for AV1
914 sd = ff_get_coded_side_data(avctx, AV_PKT_DATA_DOVI_CONF);
915 if (sd && sd->size >= sizeof(s->dovi.cfg))
916 s->dovi.cfg = *(AVDOVIDecoderConfigurationRecord *) sd->data;
917
918 return ret;

Callers

nothing calls this directly

Calls 5

av_fifo_alloc2Function · 0.85
av_opt_set_intFunction · 0.85
av_logFunction · 0.85
ff_get_coded_side_dataFunction · 0.85

Tested by

no test coverage detected