| 2554 | } |
| 2555 | |
| 2556 | static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, |
| 2557 | int *got_output, AVPacket *avpkt) |
| 2558 | { |
| 2559 | const uint8_t *buf = avpkt->data; |
| 2560 | int ret; |
| 2561 | int buf_size = avpkt->size; |
| 2562 | Mpeg1Context *s = avctx->priv_data; |
| 2563 | MPVContext *const s2 = &s->slice.c; |
| 2564 | |
| 2565 | if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) { |
| 2566 | /* special case for last picture */ |
| 2567 | if (s2->low_delay == 0 && s2->next_pic.ptr) { |
| 2568 | int ret = av_frame_ref(picture, s2->next_pic.ptr->f); |
| 2569 | if (ret < 0) |
| 2570 | return ret; |
| 2571 | |
| 2572 | ff_mpv_unref_picture(&s2->next_pic); |
| 2573 | |
| 2574 | *got_output = 1; |
| 2575 | } |
| 2576 | return buf_size; |
| 2577 | } |
| 2578 | |
| 2579 | if (!s2->context_initialized && |
| 2580 | (s2->codec_tag == AV_RL32("VCR2") || s2->codec_tag == AV_RL32("BW10"))) |
| 2581 | vcr2_init_sequence(avctx); |
| 2582 | |
| 2583 | s->slice_count = 0; |
| 2584 | |
| 2585 | if (avctx->extradata && !s->extradata_decoded) { |
| 2586 | ret = decode_chunks(avctx, picture, got_output, |
| 2587 | avctx->extradata, avctx->extradata_size); |
| 2588 | if (*got_output) { |
| 2589 | av_log(avctx, AV_LOG_ERROR, "picture in extradata\n"); |
| 2590 | av_frame_unref(picture); |
| 2591 | *got_output = 0; |
| 2592 | } |
| 2593 | s->extradata_decoded = 1; |
| 2594 | if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) { |
| 2595 | ff_mpv_unref_picture(&s2->cur_pic); |
| 2596 | return ret; |
| 2597 | } |
| 2598 | } |
| 2599 | |
| 2600 | ret = decode_chunks(avctx, picture, got_output, buf, buf_size); |
| 2601 | if (ret<0 || *got_output) { |
| 2602 | ff_mpv_unref_picture(&s2->cur_pic); |
| 2603 | |
| 2604 | if (s->timecode_frame_start != -1 && *got_output) { |
| 2605 | char tcbuf[AV_TIMECODE_STR_SIZE]; |
| 2606 | AVFrameSideData *tcside = av_frame_new_side_data(picture, |
| 2607 | AV_FRAME_DATA_GOP_TIMECODE, |
| 2608 | sizeof(int64_t)); |
| 2609 | if (!tcside) |
| 2610 | return AVERROR(ENOMEM); |
| 2611 | memcpy(tcside->data, &s->timecode_frame_start, sizeof(int64_t)); |
| 2612 | |
| 2613 | av_timecode_make_mpeg_tc_string(tcbuf, s->timecode_frame_start); |
nothing calls this directly
no test coverage detected