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

Function mpeg_decode_postinit

libavcodec/mpeg12dec.c:862–975  ·  view source on GitHub ↗

Call this function when we know all parameters. * It may be called in different places for MPEG-1 and MPEG-2. */

Source from the content-addressed store, hash-verified

860/* Call this function when we know all parameters.
861 * It may be called in different places for MPEG-1 and MPEG-2. */
862static int mpeg_decode_postinit(AVCodecContext *avctx)
863{
864 Mpeg1Context *s1 = avctx->priv_data;
865 MPVContext *const s = &s1->slice.c;
866 int ret;
867
868 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
869 // MPEG-1 aspect
870 AVRational aspect_inv = av_d2q(ff_mpeg1_aspect[s1->aspect_ratio_info], 255);
871 avctx->sample_aspect_ratio = (AVRational) { aspect_inv.den, aspect_inv.num };
872 } else { // MPEG-2
873 // MPEG-2 aspect
874 if (s1->aspect_ratio_info > 1) {
875 AVRational dar =
876 av_mul_q(av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
877 (AVRational) { s1->pan_scan.width,
878 s1->pan_scan.height }),
879 (AVRational) { s->width, s->height });
880
881 /* We ignore the spec here and guess a bit as reality does not
882 * match the spec, see for example res_change_ffmpeg_aspect.ts
883 * and sequence-display-aspect.mpg.
884 * issue1613, 621, 562 */
885 if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
886 (av_cmp_q(dar, (AVRational) { 4, 3 }) &&
887 av_cmp_q(dar, (AVRational) { 16, 9 }))) {
888 s->avctx->sample_aspect_ratio =
889 av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
890 (AVRational) { s->width, s->height });
891 } else {
892 s->avctx->sample_aspect_ratio =
893 av_div_q(ff_mpeg2_aspect[s1->aspect_ratio_info],
894 (AVRational) { s1->pan_scan.width, s1->pan_scan.height });
895// issue1613 4/3 16/9 -> 16/9
896// res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
897// widescreen-issue562.mpg 4/3 16/9 -> 16/9
898// s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height});
899 ff_dlog(avctx, "aspect A %d/%d\n",
900 ff_mpeg2_aspect[s1->aspect_ratio_info].num,
901 ff_mpeg2_aspect[s1->aspect_ratio_info].den);
902 ff_dlog(avctx, "aspect B %d/%d\n", s->avctx->sample_aspect_ratio.num,
903 s->avctx->sample_aspect_ratio.den);
904 }
905 } else {
906 s->avctx->sample_aspect_ratio =
907 ff_mpeg2_aspect[s1->aspect_ratio_info];
908 }
909 } // MPEG-2
910
911 if (av_image_check_sar(s->width, s->height,
912 avctx->sample_aspect_ratio) < 0) {
913 av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
914 avctx->sample_aspect_ratio.num,
915 avctx->sample_aspect_ratio.den);
916 avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
917 }
918
919 if (!s->context_initialized ||

Callers 1

decode_chunksFunction · 0.85

Calls 12

av_d2qFunction · 0.85
av_mul_qFunction · 0.85
av_div_qFunction · 0.85
av_cmp_qFunction · 0.85
av_image_check_sarFunction · 0.85
av_logFunction · 0.85
ff_mpv_common_endFunction · 0.85
ff_set_dimensionsFunction · 0.85
av_reduceFunction · 0.85
mpeg_get_pixelformatFunction · 0.85
ff_mpv_common_initFunction · 0.85
ff_mpv_framesize_disableFunction · 0.85

Tested by

no test coverage detected