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

Function decode_frame

libavcodec/v210dec.c:136–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
137 int *got_frame, AVPacket *avpkt)
138{
139 V210DecContext *s = avctx->priv_data;
140 ThreadData td;
141 int ret, stride, aligned_input;
142 const uint8_t *psrc = avpkt->data;
143
144 if (s->custom_stride )
145 stride = s->custom_stride > 0 ? s->custom_stride : 0;
146 else {
147 stride = v210_stride(avctx->width, 48);
148 if (avpkt->size < stride * avctx->height) {
149 int align;
150 for (align = 24; align >= 6; align >>= 1) {
151 int small_stride = v210_stride(avctx->width, align);
152 if (avpkt->size == small_stride * avctx->height) {
153 stride = small_stride;
154 if (!s->stride_warning_shown)
155 av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (%d byte) detected\n", align * 8 / 3);
156 s->stride_warning_shown = 1;
157 break;
158 }
159 }
160 if (align < 6 && avctx->codec_tag == MKTAG('b', 'x', 'y', '2'))
161 stride = 0;
162 }
163 }
164
165 if (stride == 0 && ((avctx->width & 1) || (int64_t)avctx->width * avctx->height > INT_MAX / 6)) {
166 av_log(avctx, AV_LOG_ERROR, "Strideless v210 is not supported for size %dx%d\n", avctx->width, avctx->height);
167 return AVERROR_INVALIDDATA;
168 }
169
170 if (stride > 0 && avpkt->size < (int64_t)stride * avctx->height ||
171 stride == 0 && avpkt->size < v210_stride(avctx->width * avctx->height, 6)) {
172 av_log(avctx, AV_LOG_ERROR, "packet too small\n");
173 return AVERROR_INVALIDDATA;
174 }
175 if ( avctx->codec_tag == MKTAG('C', '2', '1', '0')
176 && avpkt->size > 64
177 && AV_RN32(psrc) == AV_RN32("INFO")
178 && avpkt->size - 64 >= stride * avctx->height)
179 psrc += 64;
180
181 aligned_input = !((uintptr_t)psrc & 0x1f) && !(stride & 0x1f);
182 if (aligned_input != s->aligned_input) {
183 s->aligned_input = aligned_input;
184 ff_v210dec_init(s);
185 }
186
187 if ((ret = ff_thread_get_buffer(avctx, pic, 0)) < 0)
188 return ret;
189
190 if (stride) {
191 td.stride = stride;
192 td.buf = psrc;
193 td.frame = pic;

Callers

nothing calls this directly

Calls 9

v210_strideFunction · 0.85
av_logFunction · 0.85
AV_RN32Function · 0.85
ff_v210dec_initFunction · 0.85
av_image_allocFunction · 0.85
decode_rowFunction · 0.85
av_image_copy2Function · 0.85
av_freepFunction · 0.85
ff_thread_get_bufferFunction · 0.70

Tested by

no test coverage detected