Unified · Split
| @@ -738,32 +738,8 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx) · 737 unmodified lines | ||
| 738 | 738 | /* Disable slices when the version doesn't support them */ |
| 739 | 739 | s->num_h_slices = 1; |
| 740 | 740 | s->num_v_slices = 1; |
| 741 | − } else { | |
| 742 | − if ((ret = encode_determine_slices(avctx)) < 0) | |
| 743 | − return ret; | |
| 744 | − | |
| 745 | − if ((ret = ff_ffv1_write_extradata(avctx)) < 0) | |
| 746 | − return ret; | |
| 747 | − } | |
| 748 | − | |
| 749 | − if ((ret = ff_ffv1_init_slice_contexts(s)) < 0) | |
| 750 | − return ret; | |
| 751 | − s->slice_count = s->max_slice_count; | |
| 752 | − | |
| 753 | − for (int j = 0; j < s->slice_count; j++) { | |
| 754 | − for (int i = 0; i < s->plane_count; i++) { | |
| 755 | − PlaneContext *const p = &s->slices[j].plane[i]; | |
| 756 | − | |
| 757 | − p->quant_table_index = s->context_model; | |
| 758 | − p->context_count = s->context_count[p->quant_table_index]; | |
| 759 | − } | |
| 760 | − | |
| 761 | − ff_build_rac_states(&s->slices[j].c, 0.05 * (1LL << 32), 256 - 8); | |
| 762 | 741 | } |
| 763 | 742 | |
| 764 | − if ((ret = ff_ffv1_init_slices_state(s)) < 0) | |
| 765 | − return ret; | |
| 766 | − | |
| 767 | 743 | return 0; |
| 768 | 744 | } |
| 769 | 745 | |
| @@ -942,6 +918,30 @@ static int encode_init_internal(AVCodecContext *avctx) · 172 unmodified lines | ||
| 942 | 918 | if (ret < 0) |
| 943 | 919 | return ret; |
| 944 | 920 | |
| 921 | + if ((ret = encode_determine_slices(avctx)) < 0) | |
| 922 | + return ret; | |
| 923 | + | |
| 924 | + if ((ret = ff_ffv1_write_extradata(avctx)) < 0) | |
| 925 | + return ret; | |
| 926 | + | |
| 927 | + if ((ret = ff_ffv1_init_slice_contexts(s)) < 0) | |
| 928 | + return ret; | |
| 929 | + s->slice_count = s->max_slice_count; | |
| 930 | + | |
| 931 | + for (int j = 0; j < s->slice_count; j++) { | |
| 932 | + for (int i = 0; i < s->plane_count; i++) { | |
| 933 | + PlaneContext *const p = &s->slices[j].plane[i]; | |
| 934 | + | |
| 935 | + p->quant_table_index = s->context_model; | |
| 936 | + p->context_count = s->context_count[p->quant_table_index]; | |
| 937 | + } | |
| 938 | + | |
| 939 | + ff_build_rac_states(&s->slices[j].c, 0.05 * (1LL << 32), 256 - 8); | |
| 940 | + } | |
| 941 | + | |
| 942 | + if ((ret = ff_ffv1_init_slices_state(s)) < 0) | |
| 943 | + return ret; | |
| 944 | + | |
| 945 | 945 | #define STATS_OUT_SIZE 1024 * 1024 * 6 |
| 946 | 946 | if (avctx->flags & AV_CODEC_FLAG_PASS1) { |
| 947 | 947 | avctx->stats_out = av_mallocz(STATS_OUT_SIZE); |