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

Function hcom_decode

libavcodec/hcom.c:84–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84static int hcom_decode(AVCodecContext *avctx, AVFrame *frame,
85 int *got_frame, AVPacket *pkt)
86{
87 HCOMContext *s = avctx->priv_data;
88 GetBitContext gb;
89 int ret, n = 0;
90
91 if (pkt->size > INT16_MAX)
92 return AVERROR_INVALIDDATA;
93
94 frame->nb_samples = pkt->size * 8;
95 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
96 return ret;
97
98 if ((ret = init_get_bits8(&gb, pkt->data, pkt->size)) < 0)
99 return ret;
100
101 while (get_bits_left(&gb) > 0) {
102 if (get_bits1(&gb))
103 s->dict_entry = s->dict[s->dict_entry].r;
104 else
105 s->dict_entry = s->dict[s->dict_entry].l;
106
107 if (s->dict[s->dict_entry].l < 0) {
108 int16_t datum;
109
110 datum = s->dict[s->dict_entry].r;
111
112 if (!s->delta_compression)
113 s->sample = 0;
114 s->sample = (s->sample + datum) & 0xFF;
115
116 frame->data[0][n++] = s->sample;
117
118 s->dict_entry = 0;
119 }
120 }
121
122 frame->nb_samples = n;
123
124 *got_frame = 1;
125
126 return pkt->size;
127}
128
129static av_cold int hcom_close(AVCodecContext *avctx)
130{

Callers

nothing calls this directly

Calls 4

ff_get_bufferFunction · 0.85
init_get_bits8Function · 0.85
get_bits_leftFunction · 0.85
get_bits1Function · 0.85

Tested by

no test coverage detected