libavcodec/mpeg2_metadata_bsf.c:157: error: Uninitialized Value
  The value read from ext_n was never initialized.

libavcodec/mpeg2_metadata_bsf.c:157:9: 
155.     found_frame_rate:
156.         sh->frame_rate_code        = code;
157.         se->frame_rate_extension_n = ext_n - 1;
             ^
158.         se->frame_rate_extension_d = ext_d - 1;
159.     }

static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
                                          CodedBitstreamFragment *frag)
{
    MPEG2MetadataContext             *ctx = bsf->priv_data;
    MPEG2RawSequenceHeader            *sh = NULL;
    MPEG2RawSequenceExtension         *se = NULL;
    MPEG2RawSequenceDisplayExtension *sde = NULL;
    int i, se_pos, add_sde = 0;
    for (i = 0; i < frag->nb_units; i++) {
        if (frag->units[i].type == MPEG2_START_SEQUENCE_HEADER) {
            sh = frag->units[i].content;
        } else if (frag->units[i].type == MPEG2_START_EXTENSION) {
            MPEG2RawExtensionData *ext = frag->units[i].content;
            if (ext->extension_start_code_identifier ==
                MPEG2_EXTENSION_SEQUENCE) {
                se = &ext->data.sequence;
                se_pos = i;
            } else if (ext->extension_start_code_identifier ==
                MPEG2_EXTENSION_SEQUENCE_DISPLAY) {
                sde = &ext->data.sequence_display;
            }
        }
    }
    if (!sh || !se) {
        if (sh && !ctx->mpeg1_warned) {
            av_log(bsf, AV_LOG_WARNING, "Stream contains a sequence "
                   "header but not a sequence extension: maybe it's "
                   "actually MPEG-1?\n");
            ctx->mpeg1_warned = 1;
        }
        return 0;
    }
    if (ctx->display_aspect_ratio.num && ctx->display_aspect_ratio.den) {
        int num, den;
        av_reduce(&num, &den, ctx->display_aspect_ratio.num,
                  ctx->display_aspect_ratio.den, 65535);
        if (num == 4 && den == 3)
            sh->aspect_ratio_information = 2;
        else if (num == 16 && den == 9)
            sh->aspect_ratio_information = 3;
        else if (num == 221 && den == 100)
            sh->aspect_ratio_information = 4;
        else
            sh->aspect_ratio_information = 1;
    }
    if (ctx->frame_rate.num && ctx->frame_rate.den) {
        static AVRational frame_rate_table[] = {
            { 0, 0 },
            { 24000, 1001 },
            { 24,    1    },
            { 25,    1    },
            { 30000, 1001 },
            { 30,    1    },
            { 50,    1    },
            { 60000, 1001 },
            { 60,    1    },
        };
        int code, ext_n, ext_d;
        AVRational best_error = { INT_MAX, 1 };
        for (i = 1; i < FF_ARRAY_ELEMS(frame_rate_table); i++) {
            if (av_cmp_q(ctx->frame_rate, frame_rate_table[i]) == 0) {
                code  = i;
                ext_n = 1;
                ext_d = 1;
                goto found_frame_rate;
            }
        }
        for (i = 1; i < FF_ARRAY_ELEMS(frame_rate_table); i++) {
            AVRational fr, error;
            int n, d, cmp;
            for (n = 1; n <= 4; n++) {
                for (d = 1; d <= 32; d++) {
                    fr = av_mul_q(frame_rate_table[i],
                                  (AVRational) { n, d });
                    cmp = av_cmp_q(fr, ctx->frame_rate);
                    if (cmp == 0) {
                        code  = i;
                        ext_n = n;
                        ext_d = d;
                        goto found_frame_rate;
                    }
                    if (cmp < 0)
                        error = av_div_q(ctx->frame_rate, fr);
                    else
                        error = av_div_q(fr, ctx->frame_rate);
                    cmp = av_cmp_q(error, best_error);
                    if (cmp < 0 || (cmp == 0 && n == 1 && d == 1)) {
                        code  = i;
                        ext_n = n;
                        ext_d = d;
                        best_error = error;
                    }
                }
            }
        }
    found_frame_rate:
        sh->frame_rate_code        = code;
        se->frame_rate_extension_n = ext_n - 1;
        se->frame_rate_extension_d = ext_d - 1;
    }
    if (ctx->video_format             >= 0 ||
        ctx->colour_primaries         >= 0 ||
        ctx->transfer_characteristics >= 0 ||
        ctx->matrix_coefficients      >= 0) {
        if (!sde) {
            add_sde = 1;
            ctx->sequence_display_extension.extension_start_code =
                MPEG2_START_EXTENSION;
            ctx->sequence_display_extension.extension_start_code_identifier =
                MPEG2_EXTENSION_SEQUENCE_DISPLAY;
            sde = &ctx->sequence_display_extension.data.sequence_display;
            *sde = (MPEG2RawSequenceDisplayExtension) {
                .video_format = 5,
                .colour_description       = 0,
                .colour_primaries         = 2,
                .transfer_characteristics = 2,
                .matrix_coefficients      = 2,
                .display_horizontal_size =
                    se->horizontal_size_extension << 12 | sh->horizontal_size_value,
                .display_vertical_size =
                    se->vertical_size_extension << 12 | sh->vertical_size_value,
            };
        }
        if (ctx->video_format >= 0)
            sde->video_format = ctx->video_format;
        if (ctx->colour_primaries         >= 0 ||
            ctx->transfer_characteristics >= 0 ||
            ctx->matrix_coefficients      >= 0) {
            sde->colour_description = 1;
            if (ctx->colour_primaries >= 0)
                sde->colour_primaries = ctx->colour_primaries;
            else if (add_sde)
                sde->colour_primaries = 2;
            if (ctx->transfer_characteristics >= 0)
                sde->transfer_characteristics = ctx->transfer_characteristics;
            else if (add_sde)
                sde->transfer_characteristics = 2;
            if (ctx->matrix_coefficients >= 0)
                sde->matrix_coefficients = ctx->matrix_coefficients;
            else if (add_sde)
                sde->matrix_coefficients = 2;
        }
    }
    if (add_sde) {
        int err;
        err = ff_cbs_insert_unit_content(&ctx->cbc, frag, se_pos + 1,
                                         MPEG2_START_EXTENSION,
                                         &ctx->sequence_display_extension);
        if (err < 0) {
            av_log(bsf, AV_LOG_ERROR, "Failed to insert new sequence "
                   "display extension.\n");
            return err;
        }
    }
    return 0;
}
['static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,\n                                          CodedBitstreamFragment *frag)\n{\n    MPEG2MetadataContext             *ctx = bsf->priv_data;\n    MPEG2RawSequenceHeader            *sh = NULL;\n    MPEG2RawSequenceExtension         *se = NULL;\n    MPEG2RawSequenceDisplayExtension *sde = NULL;\n    int i, se_pos, add_sde = 0;\n    for (i = 0; i < frag->nb_units; i++) {\n        if (frag->units[i].type == MPEG2_START_SEQUENCE_HEADER) {\n            sh = frag->units[i].content;\n        } else if (frag->units[i].type == MPEG2_START_EXTENSION) {\n            MPEG2RawExtensionData *ext = frag->units[i].content;\n            if (ext->extension_start_code_identifier ==\n                MPEG2_EXTENSION_SEQUENCE) {\n                se = &ext->data.sequence;\n                se_pos = i;\n            } else if (ext->extension_start_code_identifier ==\n                MPEG2_EXTENSION_SEQUENCE_DISPLAY) {\n                sde = &ext->data.sequence_display;\n            }\n        }\n    }\n    if (!sh || !se) {\n        if (sh && !ctx->mpeg1_warned) {\n            av_log(bsf, AV_LOG_WARNING, "Stream contains a sequence "\n                   "header but not a sequence extension: maybe it\'s "\n                   "actually MPEG-1?\\n");\n            ctx->mpeg1_warned = 1;\n        }\n        return 0;\n    }\n    if (ctx->display_aspect_ratio.num && ctx->display_aspect_ratio.den) {\n        int num, den;\n        av_reduce(&num, &den, ctx->display_aspect_ratio.num,\n                  ctx->display_aspect_ratio.den, 65535);\n        if (num == 4 && den == 3)\n            sh->aspect_ratio_information = 2;\n        else if (num == 16 && den == 9)\n            sh->aspect_ratio_information = 3;\n        else if (num == 221 && den == 100)\n            sh->aspect_ratio_information = 4;\n        else\n            sh->aspect_ratio_information = 1;\n    }\n    if (ctx->frame_rate.num && ctx->frame_rate.den) {\n        static AVRational frame_rate_table[] = {\n            { 0, 0 },\n            { 24000, 1001 },\n            { 24,    1    },\n            { 25,    1    },\n            { 30000, 1001 },\n            { 30,    1    },\n            { 50,    1    },\n            { 60000, 1001 },\n            { 60,    1    },\n        };\n        int code, ext_n, ext_d;\n        AVRational best_error = { INT_MAX, 1 };\n        for (i = 1; i < FF_ARRAY_ELEMS(frame_rate_table); i++) {\n            if (av_cmp_q(ctx->frame_rate, frame_rate_table[i]) == 0) {\n                code  = i;\n                ext_n = 1;\n                ext_d = 1;\n                goto found_frame_rate;\n            }\n        }\n        for (i = 1; i < FF_ARRAY_ELEMS(frame_rate_table); i++) {\n            AVRational fr, error;\n            int n, d, cmp;\n            for (n = 1; n <= 4; n++) {\n                for (d = 1; d <= 32; d++) {\n                    fr = av_mul_q(frame_rate_table[i],\n                                  (AVRational) { n, d });\n                    cmp = av_cmp_q(fr, ctx->frame_rate);\n                    if (cmp == 0) {\n                        code  = i;\n                        ext_n = n;\n                        ext_d = d;\n                        goto found_frame_rate;\n                    }\n                    if (cmp < 0)\n                        error = av_div_q(ctx->frame_rate, fr);\n                    else\n                        error = av_div_q(fr, ctx->frame_rate);\n                    cmp = av_cmp_q(error, best_error);\n                    if (cmp < 0 || (cmp == 0 && n == 1 && d == 1)) {\n                        code  = i;\n                        ext_n = n;\n                        ext_d = d;\n                        best_error = error;\n                    }\n                }\n            }\n        }\n    found_frame_rate:\n        sh->frame_rate_code        = code;\n        se->frame_rate_extension_n = ext_n - 1;\n        se->frame_rate_extension_d = ext_d - 1;\n    }\n    if (ctx->video_format             >= 0 ||\n        ctx->colour_primaries         >= 0 ||\n        ctx->transfer_characteristics >= 0 ||\n        ctx->matrix_coefficients      >= 0) {\n        if (!sde) {\n            add_sde = 1;\n            ctx->sequence_display_extension.extension_start_code =\n                MPEG2_START_EXTENSION;\n            ctx->sequence_display_extension.extension_start_code_identifier =\n                MPEG2_EXTENSION_SEQUENCE_DISPLAY;\n            sde = &ctx->sequence_display_extension.data.sequence_display;\n            *sde = (MPEG2RawSequenceDisplayExtension) {\n                .video_format = 5,\n                .colour_description       = 0,\n                .colour_primaries         = 2,\n                .transfer_characteristics = 2,\n                .matrix_coefficients      = 2,\n                .display_horizontal_size =\n                    se->horizontal_size_extension << 12 | sh->horizontal_size_value,\n                .display_vertical_size =\n                    se->vertical_size_extension << 12 | sh->vertical_size_value,\n            };\n        }\n        if (ctx->video_format >= 0)\n            sde->video_format = ctx->video_format;\n        if (ctx->colour_primaries         >= 0 ||\n            ctx->transfer_characteristics >= 0 ||\n            ctx->matrix_coefficients      >= 0) {\n            sde->colour_description = 1;\n            if (ctx->colour_primaries >= 0)\n                sde->colour_primaries = ctx->colour_primaries;\n            else if (add_sde)\n                sde->colour_primaries = 2;\n            if (ctx->transfer_characteristics >= 0)\n                sde->transfer_characteristics = ctx->transfer_characteristics;\n            else if (add_sde)\n                sde->transfer_characteristics = 2;\n            if (ctx->matrix_coefficients >= 0)\n                sde->matrix_coefficients = ctx->matrix_coefficients;\n            else if (add_sde)\n                sde->matrix_coefficients = 2;\n        }\n    }\n    if (add_sde) {\n        int err;\n        err = ff_cbs_insert_unit_content(&ctx->cbc, frag, se_pos + 1,\n                                         MPEG2_START_EXTENSION,\n                                         &ctx->sequence_display_extension);\n        if (err < 0) {\n            av_log(bsf, AV_LOG_ERROR, "Failed to insert new sequence "\n                   "display extension.\\n");\n            return err;\n        }\n    }\n    return 0;\n}']