export coded and cropped frame dimensions to AVCodecContext */
| 924 | |
| 925 | /* export coded and cropped frame dimensions to AVCodecContext */ |
| 926 | static void init_dimensions(H264Context *h) |
| 927 | { |
| 928 | const SPS *sps = h->ps.sps; |
| 929 | int cr = sps->crop_right; |
| 930 | int cl = sps->crop_left; |
| 931 | int ct = sps->crop_top; |
| 932 | int cb = sps->crop_bottom; |
| 933 | int width = h->width - (cr + cl); |
| 934 | int height = h->height - (ct + cb); |
| 935 | av_assert0(sps->crop_right + sps->crop_left < (unsigned)h->width); |
| 936 | av_assert0(sps->crop_top + sps->crop_bottom < (unsigned)h->height); |
| 937 | |
| 938 | /* handle container cropping */ |
| 939 | if (h->width_from_caller > 0 && h->height_from_caller > 0 && |
| 940 | !sps->crop_top && !sps->crop_left && |
| 941 | FFALIGN(h->width_from_caller, 16) == FFALIGN(width, 16) && |
| 942 | FFALIGN(h->height_from_caller, 16) == FFALIGN(height, 16) && |
| 943 | h->width_from_caller <= width && |
| 944 | h->height_from_caller <= height) { |
| 945 | width = h->width_from_caller; |
| 946 | height = h->height_from_caller; |
| 947 | cl = 0; |
| 948 | ct = 0; |
| 949 | cr = h->width - width; |
| 950 | cb = h->height - height; |
| 951 | } else { |
| 952 | h->width_from_caller = 0; |
| 953 | h->height_from_caller = 0; |
| 954 | } |
| 955 | |
| 956 | h->avctx->coded_width = h->width; |
| 957 | h->avctx->coded_height = h->height; |
| 958 | h->avctx->width = width; |
| 959 | h->avctx->height = height; |
| 960 | h->crop_right = cr; |
| 961 | h->crop_left = cl; |
| 962 | h->crop_top = ct; |
| 963 | h->crop_bottom = cb; |
| 964 | } |
| 965 | |
| 966 | static int h264_slice_header_init(H264Context *h) |
| 967 | { |