static int dv_read_timecode(AVFormatContext *s) {

    int ret;

    char timecode[AV_TIMECODE_STR_SIZE];

    int64_t pos = avio_tell(s->pb);



    // Read 3 DIF blocks: Header block and 2 Subcode blocks.

    int partial_frame_size = 3 * 80;

    uint8_t *partial_frame = av_mallocz(sizeof(*partial_frame) *

                                        partial_frame_size);



    RawDVContext *c = s->priv_data;

    ret = avio_read(s->pb, partial_frame, partial_frame_size);

    if (ret < 0)

        goto finish;



    if (ret < partial_frame_size) {

        ret = -1;

        goto finish;

    }



    ret = dv_extract_timecode(c->dv_demux, partial_frame, timecode);

    if (ret)

        av_dict_set(&s->metadata, "timecode", timecode, 0);

    else if (ret < 0)

        av_log(s, AV_LOG_ERROR, "Detected timecode is invalid\n");



finish:

    av_free(partial_frame);

    avio_seek(s->pb, pos, SEEK_SET);

    return ret;

}

static int dv_read_timecode(AVFormatContext *s) {

    int ret;

    char timecode[AV_TIMECODE_STR_SIZE];

    int64_t pos = avio_tell(s->pb);



    

    int partial_frame_size = 3 * 80;

    uint8_t *partial_frame = av_mallocz(sizeof(*partial_frame) *

                                        partial_frame_size);



    RawDVContext *c = s->priv_data;

    ret = avio_read(s->pb, partial_frame, partial_frame_size);

    if (ret < 0)

        goto finish;



    if (ret < partial_frame_size) {

        ret = -1;

        goto finish;

    }



    ret = dv_extract_timecode(c->dv_demux, partial_frame, timecode);

    if (ret)

        av_dict_set(&s->metadata, "timecode", timecode, 0);

    else if (ret < 0)

        av_log(s, AV_LOG_ERROR, "Detected timecode is invalid\n");



finish:

    av_free(partial_frame);

    avio_seek(s->pb, pos, SEEK_SET);

    return ret;

}

static int FUNC_0(AVFormatContext *VAR_0) {

    int VAR_1;

    char VAR_2[AV_TIMECODE_STR_SIZE];

    int64_t pos = avio_tell(VAR_0->pb);



    

    int VAR_3 = 3 * 80;

    uint8_t *partial_frame = av_mallocz(sizeof(*partial_frame) *

                                        VAR_3);



    RawDVContext *c = VAR_0->priv_data;

    VAR_1 = avio_read(VAR_0->pb, partial_frame, VAR_3);

    if (VAR_1 < 0)

        goto finish;



    if (VAR_1 < VAR_3) {

        VAR_1 = -1;

        goto finish;

    }



    VAR_1 = dv_extract_timecode(c->dv_demux, partial_frame, VAR_2);

    if (VAR_1)

        av_dict_set(&VAR_0->metadata, "VAR_2", VAR_2, 0);

    else if (VAR_1 < 0)

        av_log(VAR_0, AV_LOG_ERROR, "Detected VAR_2 is invalid\n");



finish:

    av_free(partial_frame);

    avio_seek(VAR_0->pb, pos, SEEK_SET);

    return VAR_1;

}

static int FUNC_0(AVFormatContext *VAR_0) { int VAR_1; char VAR_2[AV_TIMECODE_STR_SIZE]; int64_t pos = avio_tell(VAR_0->pb); int VAR_3 = 3 * 80; uint8_t *partial_frame = av_mallocz(sizeof(*partial_frame) *
VAR_3); RawDVContext *c = VAR_0->priv_data; VAR_1 = avio_read(VAR_0->pb, partial_frame, VAR_3); if (VAR_1 < 0)
goto finish; if (VAR_1 < VAR_3) { VAR_1 = -1; goto finish; } VAR_1 = dv_extract_timecode(c->dv_demux, partial_frame, VAR_2); if (VAR_1)
av_dict_set(&VAR_0->metadata, "VAR_2", VAR_2, 0); else if (VAR_1 < 0)
av_log(VAR_0, AV_LOG_ERROR, "Detected VAR_2 is invalid\n"); finish:
av_free(partial_frame); avio_seek(VAR_0->pb, pos, SEEK_SET); return VAR_1; }