History

ffv1enc: move slice allocation out of generic encode init

Lynne committed 2 years ago

Commit a6c58351 parent 12ea1cd1 file · +24 −24Browse files

Unified · Split

libavcodec/ffv1enc.c+24−24
@@ -738,32 +738,8 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx) · 737 unmodified lines
738 /* Disable slices when the version doesn't support them */738 /* Disable slices when the version doesn't support them */
739 s->num_h_slices = 1;739 s->num_h_slices = 1;
740 s->num_v_slices = 1;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 return 0;743 return 0;
768}744}
769 745
@@ -942,6 +918,30 @@ static int encode_init_internal(AVCodecContext *avctx) · 172 unmodified lines
942 if (ret < 0)918 if (ret < 0)
943 return ret;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#define STATS_OUT_SIZE 1024 * 1024 * 6945#define STATS_OUT_SIZE 1024 * 1024 * 6
946 if (avctx->flags & AV_CODEC_FLAG_PASS1) {946 if (avctx->flags & AV_CODEC_FLAG_PASS1) {
947 avctx->stats_out = av_mallocz(STATS_OUT_SIZE);947 avctx->stats_out = av_mallocz(STATS_OUT_SIZE);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t