+ {
+ *unescaped_buf_ptr = *buf_ptr;
+ *unescaped_buf_size = buf_end - *buf_ptr;
+ }
+
+ return start_code;
+}
+
+int ff_mjpeg_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ MJpegDecodeContext *s = avctx->priv_data;
+ const uint8_t *buf_end, *buf_ptr;
+ const uint8_t *unescaped_buf_ptr;
+ int unescaped_buf_size;
+ int start_code;
+ AVFrame *picture = data;
+
+ s->got_picture = 0; // picture from previous image can not be reused
+ buf_ptr = buf;
+ buf_end = buf + buf_size;
+ while (buf_ptr < buf_end) {
+ /* find start next marker */
+ start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end,
+ &unescaped_buf_ptr, &unescaped_buf_size);
+ {
+ /* EOF */
+ if (start_code < 0) {
+ goto the_end;
+ } else {
+ av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n", start_code, buf_end - buf_ptr);
+
+ init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size*8);