History

avcodec/mpegvideo: Move sequence-level properties to MPVMainEncContext

Andreas Rheinhardt committed 1 year ago

Commit b7106981 parent d9dea706 files · +71 −68Browse files

Unified · Split

6 files
  1. libavcodec/mpeg12enc.c +8 −6
  2. libavcodec/mpeg12enc.h +2 −2
  3. libavcodec/mpegvideo.h +0 −15
  4. libavcodec/mpegvideo_enc.c +43 −43
  5. libavcodec/mpegvideoenc.h +16 −0
  6. libavcodec/ratecontrol.c +2 −2
libavcodec/mpeg12enc.c+8−6
@@ -144,9 +144,9 @@ static void put_header(MpegEncContext *s, uint32_t header) · 143 unmodified lines
144}144}
145 145
146/* put sequence header if needed */146/* put sequence header if needed */
147static void mpeg1_encode_sequence_header(MpegEncContext *s)147static void mpeg1_encode_sequence_header(MPEG12EncContext *mpeg12)
148{148{
149 MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;149 MpegEncContext *const s = &mpeg12->mpeg.s;
150 unsigned int vbv_buffer_size, fps, v;150 unsigned int vbv_buffer_size, fps, v;
151 int constraint_parameter_flag;151 int constraint_parameter_flag;
152 AVRational framerate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index];152 AVRational framerate = ff_mpeg12_frame_rate_tab[mpeg12->frame_rate_index];
@@ -299,7 +299,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) · 146 unmodified lines
299 put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));299 put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
300 put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));300 put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
301 put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) ||301 put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) ||
302 s->intra_only || !mpeg12->gop_picture_number);302 mpeg12->mpeg.intra_only || !mpeg12->gop_picture_number);
303 put_bits(&s->pb, 1, 0); // broken link303 put_bits(&s->pb, 1, 0); // broken link
304}304}
305 305
@@ -333,11 +333,13 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s) · 27 unmodified lines
333 put_bits(&s->pb, 1, 0);333 put_bits(&s->pb, 1, 0);
334}334}
335 335
336void ff_mpeg1_encode_picture_header(MpegEncContext *s)336void ff_mpeg1_encode_picture_header(MPVMainEncContext *const m)
337{337{
338 MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;338 MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)m;
339 MpegEncContext *const s = &m->s;
339 const AVFrameSideData *side_data;340 const AVFrameSideData *side_data;
340 mpeg1_encode_sequence_header(s);341
342 mpeg1_encode_sequence_header(mpeg12);
341 343
342 /* MPEG-1 picture header */344 /* MPEG-1 picture header */
343 put_header(s, PICTURE_START_CODE);345 put_header(s, PICTURE_START_CODE);
libavcodec/mpeg12enc.h+2−2
@@ -24,10 +24,10 @@ · 23 unmodified lines
24 24
25#include <stdint.h>25#include <stdint.h>
26 26
27#include "mpegvideo.h"27#include "mpegvideoenc.h"
28#include "mpegvideodata.h"28#include "mpegvideodata.h"
29 29
30void ff_mpeg1_encode_picture_header(MpegEncContext *s);30void ff_mpeg1_encode_picture_header(MPVMainEncContext *m);
31void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],31void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
32 int motion_x, int motion_y);32 int motion_x, int motion_y);
33void ff_mpeg1_encode_slice_header(MpegEncContext *s);33void ff_mpeg1_encode_slice_header(MpegEncContext *s);
libavcodec/mpegvideo.h+0−15
@@ -91,8 +91,6 @@ typedef struct MpegEncContext { · 90 unmodified lines
91 void *private_ctx;91 void *private_ctx;
92 /* the following parameters must be initialized before encoding */92 /* the following parameters must be initialized before encoding */
93 int width, height;///< picture size. must be a multiple of 1693 int width, height;///< picture size. must be a multiple of 16
94 int gop_size;
95 int intra_only; ///< if true, only intra pictures are generated
96 int64_t bit_rate; ///< wanted bit rate94 int64_t bit_rate; ///< wanted bit rate
97 enum OutputFormat out_format; ///< output format95 enum OutputFormat out_format; ///< output format
98 int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions96 int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions
@@ -114,10 +112,7 @@ typedef struct MpegEncContext { · 15 unmodified lines
114 112
115 /* sequence parameters */113 /* sequence parameters */
116 int context_initialized;114 int context_initialized;
117 int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else
118 int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else
119 int picture_number; //FIXME remove, unclear definition115 int picture_number; //FIXME remove, unclear definition
120 int picture_in_gop_number; ///< 0-> first pic in gop, ...
121 int mb_width, mb_height; ///< number of MBs horizontally & vertically116 int mb_width, mb_height; ///< number of MBs horizontally & vertically
122 int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11117 int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
123 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing118 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
@@ -131,16 +126,6 @@ typedef struct MpegEncContext { · 7 unmodified lines
131 126
132 BufferPoolContext buffer_pools;127 BufferPoolContext buffer_pools;
133 128
134 int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame()
135 /**
136 * pts difference between the first and second input frame, used for
137 * calculating dts of the first frame when there's a delay */
138 int64_t dts_delta;
139 /**
140 * reordered pts to be used as dts for the next output frame when there's
141 * a delay */
142 int64_t reordered_pts;
143
144 /** bit output */129 /** bit output */
145 PutBitContext pb;130 PutBitContext pb;
146 131
libavcodec/mpegvideo_enc.c+43−43
@@ -291,9 +291,6 @@ static av_cold void mpv_encode_defaults(MpegEncContext *s) · 290 unmodified lines
291 s->y_dc_scale_table =291 s->y_dc_scale_table =
292 s->c_dc_scale_table = ff_mpeg1_dc_scale_table;292 s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
293 }293 }
294
295 s->input_picture_number = 0;
296 s->picture_in_gop_number = 0;
297}294}
298 295
299av_cold void ff_dct_encode_init(MpegEncContext *s)296av_cold void ff_dct_encode_init(MpegEncContext *s)
@@ -354,9 +351,10 @@ static av_cold int me_cmp_init(MPVMainEncContext *const m, AVCodecContext *avctx · 54 unmodified lines
354}351}
355 352
356#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p))))353#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p))))
357static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx)354static av_cold int init_matrices(MPVMainEncContext *const m, AVCodecContext *avctx)
358{355{
359 const int nb_matrices = 1 + (s->out_format == FMT_MJPEG) + !s->intra_only;356 MpegEncContext *const s = &m->s;
357 const int nb_matrices = 1 + (s->out_format == FMT_MJPEG) + !m->intra_only;
360 const uint16_t *intra_matrix, *inter_matrix;358 const uint16_t *intra_matrix, *inter_matrix;
361 int ret;359 int ret;
362 360
@@ -368,14 +366,14 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) · 5 unmodified lines
368 s->q_chroma_intra_matrix = s->q_intra_matrix + 32;366 s->q_chroma_intra_matrix = s->q_intra_matrix + 32;
369 s->q_chroma_intra_matrix16 = s->q_intra_matrix16 + 32;367 s->q_chroma_intra_matrix16 = s->q_intra_matrix16 + 32;
370 // No need to set q_inter_matrix368 // No need to set q_inter_matrix
371 av_assert1(s->intra_only);369 av_assert1(m->intra_only);
372 // intra_matrix, chroma_intra_matrix will be set later for MJPEG.370 // intra_matrix, chroma_intra_matrix will be set later for MJPEG.
373 return 0;371 return 0;
374 } else {372 } else {
375 s->q_chroma_intra_matrix = s->q_intra_matrix;373 s->q_chroma_intra_matrix = s->q_intra_matrix;
376 s->q_chroma_intra_matrix16 = s->q_intra_matrix16;374 s->q_chroma_intra_matrix16 = s->q_intra_matrix16;
377 }375 }
378 if (!s->intra_only) {376 if (!m->intra_only) {
379 s->q_inter_matrix = s->q_intra_matrix + 32;377 s->q_inter_matrix = s->q_intra_matrix + 32;
380 s->q_inter_matrix16 = s->q_intra_matrix16 + 32;378 s->q_inter_matrix16 = s->q_intra_matrix16 + 32;
381 }379 }
@@ -460,7 +458,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 78 unmodified lines
460 avctx->gop_size, 600);458 avctx->gop_size, 600);
461 avctx->gop_size = 600;459 avctx->gop_size = 600;
462 }460 }
463 s->gop_size = avctx->gop_size;461 m->gop_size = avctx->gop_size;
464 s->avctx = avctx;462 s->avctx = avctx;
465 if (avctx->max_b_frames > MPVENC_MAX_B_FRAMES) {463 if (avctx->max_b_frames > MPVENC_MAX_B_FRAMES) {
466 av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "464 av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum "
@@ -499,13 +497,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 32 unmodified lines
499 av_log(avctx, AV_LOG_ERROR, "intra dc precision too large\n");497 av_log(avctx, AV_LOG_ERROR, "intra dc precision too large\n");
500 return AVERROR(EINVAL);498 return AVERROR(EINVAL);
501 }499 }
502 s->user_specified_pts = AV_NOPTS_VALUE;500 m->user_specified_pts = AV_NOPTS_VALUE;
503 501
504 if (s->gop_size <= 1) {502 if (m->gop_size <= 1) {
505 s->intra_only = 1;503 m->intra_only = 1;
506 s->gop_size = 12;504 m->gop_size = 12;
507 } else {505 } else {
508 s->intra_only = 0;506 m->intra_only = 0;
509 }507 }
510 508
511 /* Fixed QSCALE */509 /* Fixed QSCALE */
@@ -753,14 +751,14 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 241 unmodified lines
753 case AV_CODEC_ID_MJPEG:751 case AV_CODEC_ID_MJPEG:
754 case AV_CODEC_ID_AMV:752 case AV_CODEC_ID_AMV:
755 s->out_format = FMT_MJPEG;753 s->out_format = FMT_MJPEG;
756 s->intra_only = 1; /* force intra only for jpeg */754 m->intra_only = 1; /* force intra only for jpeg */
757 avctx->delay = 0;755 avctx->delay = 0;
758 s->low_delay = 1;756 s->low_delay = 1;
759 break;757 break;
760#endif758#endif
761 case AV_CODEC_ID_SPEEDHQ:759 case AV_CODEC_ID_SPEEDHQ:
762 s->out_format = FMT_SPEEDHQ;760 s->out_format = FMT_SPEEDHQ;
763 s->intra_only = 1; /* force intra only for SHQ */761 m->intra_only = 1; /* force intra only for SHQ */
764 avctx->delay = 0;762 avctx->delay = 0;
765 s->low_delay = 1;763 s->low_delay = 1;
766 break;764 break;
@@ -885,7 +883,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 118 unmodified lines
885 s->frame_reconstruction_bitfield = (1 << AV_PICTURE_TYPE_I) |883 s->frame_reconstruction_bitfield = (1 << AV_PICTURE_TYPE_I) |
886 (1 << AV_PICTURE_TYPE_P) |884 (1 << AV_PICTURE_TYPE_P) |
887 (1 << AV_PICTURE_TYPE_B);885 (1 << AV_PICTURE_TYPE_B);
888 } else if (!s->intra_only) {886 } else if (!m->intra_only) {
889 s->frame_reconstruction_bitfield = (1 << AV_PICTURE_TYPE_I) |887 s->frame_reconstruction_bitfield = (1 << AV_PICTURE_TYPE_I) |
890 (1 << AV_PICTURE_TYPE_P);888 (1 << AV_PICTURE_TYPE_P);
891 } else {889 } else {
@@ -916,7 +914,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 24 unmodified lines
916 !(s->picture_pool = ff_mpv_alloc_pic_pool(0)))914 !(s->picture_pool = ff_mpv_alloc_pic_pool(0)))
917 return AVERROR(ENOMEM);915 return AVERROR(ENOMEM);
918 916
919 ret = init_matrices(s, avctx);917 ret = init_matrices(m, avctx);
920 if (ret < 0)918 if (ret < 0)
921 return ret;919 return ret;
922 920
@@ -1259,11 +1257,11 @@ static int load_input_picture(MPVMainEncContext *const m, const AVFrame *pic_arg · 336 unmodified lines
1259 1257
1260 if (pic_arg) {1258 if (pic_arg) {
1261 pts = pic_arg->pts;1259 pts = pic_arg->pts;
1262 display_picture_number = s->input_picture_number++;1260 display_picture_number = m->input_picture_number++;
1263 1261
1264 if (pts != AV_NOPTS_VALUE) {1262 if (pts != AV_NOPTS_VALUE) {
1265 if (s->user_specified_pts != AV_NOPTS_VALUE) {1263 if (m->user_specified_pts != AV_NOPTS_VALUE) {
1266 int64_t last = s->user_specified_pts;1264 int64_t last = m->user_specified_pts;
1267 1265
1268 if (pts <= last) {1266 if (pts <= last) {
1269 av_log(s->avctx, AV_LOG_ERROR,1267 av_log(s->avctx, AV_LOG_ERROR,
@@ -1273,13 +1271,13 @@ static int load_input_picture(MPVMainEncContext *const m, const AVFrame *pic_arg · 3 unmodified lines
1273 }1271 }
1274 1272
1275 if (!s->low_delay && display_picture_number == 1)1273 if (!s->low_delay && display_picture_number == 1)
1276 s->dts_delta = pts - last;1274 m->dts_delta = pts - last;
1277 }1275 }
1278 s->user_specified_pts = pts;1276 m->user_specified_pts = pts;
1279 } else {1277 } else {
1280 if (s->user_specified_pts != AV_NOPTS_VALUE) {1278 if (m->user_specified_pts != AV_NOPTS_VALUE) {
1281 s->user_specified_pts =1279 m->user_specified_pts =
1282 pts = s->user_specified_pts + 1;1280 pts = m->user_specified_pts + 1;
1283 av_log(s->avctx, AV_LOG_INFO,1281 av_log(s->avctx, AV_LOG_INFO,
1284 "Warning: AVFrame.pts=? trying to guess (%"PRId64")\n",1282 "Warning: AVFrame.pts=? trying to guess (%"PRId64")\n",
1285 pts);1283 pts);
@@ -1612,7 +1610,7 @@ static int set_bframe_chain_length(MPVMainEncContext *const m) · 326 unmodified lines
1612 1610
1613 /* set next picture type & ordering */1611 /* set next picture type & ordering */
1614 if (m->frame_skip_threshold || m->frame_skip_factor) {1612 if (m->frame_skip_threshold || m->frame_skip_factor) {
1615 if (s->picture_in_gop_number < s->gop_size &&1613 if (m->picture_in_gop_number < m->gop_size &&
1616 s->next_pic.ptr &&1614 s->next_pic.ptr &&
1617 skip_check(m, s->input_picture[0], s->next_pic.ptr)) {1615 skip_check(m, s->input_picture[0], s->next_pic.ptr)) {
1618 // FIXME check that the gop check above is +-1 correct1616 // FIXME check that the gop check above is +-1 correct
@@ -1624,13 +1622,13 @@ static int set_bframe_chain_length(MPVMainEncContext *const m) · 5 unmodified lines
1624 }1622 }
1625 }1623 }
1626 1624
1627 if (/*s->picture_in_gop_number >= s->gop_size ||*/1625 if (/* m->picture_in_gop_number >= m->gop_size || */
1628 !s->next_pic.ptr || s->intra_only) {1626 !s->next_pic.ptr || m->intra_only) {
1629 s->reordered_input_picture[0] = s->input_picture[0];1627 s->reordered_input_picture[0] = s->input_picture[0];
1630 s->input_picture[0] = NULL;1628 s->input_picture[0] = NULL;
1631 s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;1629 s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
1632 s->reordered_input_picture[0]->coded_picture_number =1630 s->reordered_input_picture[0]->coded_picture_number =
1633 s->coded_picture_number++;1631 m->coded_picture_number++;
1634 } else {1632 } else {
1635 int b_frames = 0;1633 int b_frames = 0;
1636 1634
@@ -1700,10 +1698,10 @@ static int set_bframe_chain_length(MPVMainEncContext *const m) · 63 unmodified lines
1700 "warning, too many B-frames in a row\n");1698 "warning, too many B-frames in a row\n");
1701 }1699 }
1702 1700
1703 if (s->picture_in_gop_number + b_frames >= s->gop_size) {1701 if (m->picture_in_gop_number + b_frames >= m->gop_size) {
1704 if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&1702 if ((s->mpv_flags & FF_MPV_FLAG_STRICT_GOP) &&
1705 s->gop_size > s->picture_in_gop_number) {1703 m->gop_size > m->picture_in_gop_number) {
1706 b_frames = s->gop_size - s->picture_in_gop_number - 1;1704 b_frames = m->gop_size - m->picture_in_gop_number - 1;
1707 } else {1705 } else {
1708 if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)1706 if (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)
1709 b_frames = 0;1707 b_frames = 0;
@@ -1720,14 +1718,14 @@ static int set_bframe_chain_length(MPVMainEncContext *const m) · 10 unmodified lines
1720 if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)1718 if (s->reordered_input_picture[0]->f->pict_type != AV_PICTURE_TYPE_I)
1721 s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;1719 s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_P;
1722 s->reordered_input_picture[0]->coded_picture_number =1720 s->reordered_input_picture[0]->coded_picture_number =
1723 s->coded_picture_number++;1721 m->coded_picture_number++;
1724 for (int i = 0; i < b_frames; i++) {1722 for (int i = 0; i < b_frames; i++) {
1725 s->reordered_input_picture[i + 1] = s->input_picture[i];1723 s->reordered_input_picture[i + 1] = s->input_picture[i];
1726 s->input_picture[i] = NULL;1724 s->input_picture[i] = NULL;
1727 s->reordered_input_picture[i + 1]->f->pict_type =1725 s->reordered_input_picture[i + 1]->f->pict_type =
1728 AV_PICTURE_TYPE_B;1726 AV_PICTURE_TYPE_B;
1729 s->reordered_input_picture[i + 1]->coded_picture_number =1727 s->reordered_input_picture[i + 1]->coded_picture_number =
1730 s->coded_picture_number++;1728 m->coded_picture_number++;
1731 }1729 }
1732 }1730 }
1733 1731
@@ -1794,11 +1792,13 @@ fail: · 60 unmodified lines
1794 return ret;1792 return ret;
1795}1793}
1796 1794
1797static void frame_end(MpegEncContext *s)1795static void frame_end(MPVMainEncContext *const m)
1798{1796{
1797 MpegEncContext *const s = &m->s;
1798
1799 if (s->unrestricted_mv &&1799 if (s->unrestricted_mv &&
1800 s->cur_pic.reference &&1800 s->cur_pic.reference &&
1801 !s->intra_only) {1801 !m->intra_only) {
1802 int hshift = s->chroma_x_shift;1802 int hshift = s->chroma_x_shift;
1803 int vshift = s->chroma_y_shift;1803 int vshift = s->chroma_y_shift;
1804 s->mpvencdsp.draw_edges(s->cur_pic.data[0],1804 s->mpvencdsp.draw_edges(s->cur_pic.data[0],
@@ -1878,7 +1878,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, · 73 unmodified lines
1878 1878
1879 s->vbv_ignore_qmax = 0;1879 s->vbv_ignore_qmax = 0;
1880 1880
1881 s->picture_in_gop_number++;1881 m->picture_in_gop_number++;
1882 1882
1883 ret = load_input_picture(m, pic_arg);1883 ret = load_input_picture(m, pic_arg);
1884 if (ret < 0)1884 if (ret < 0)
@@ -1923,7 +1923,7 @@ vbv_retry: · 38 unmodified lines
1923 if (ret < 0)1923 if (ret < 0)
1924 return -1;1924 return -1;
1925 1925
1926 frame_end(s);1926 frame_end(m);
1927 1927
1928 if ((CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER) && s->out_format == FMT_MJPEG)1928 if ((CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER) && s->out_format == FMT_MJPEG)
1929 ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);1929 ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
@@ -2066,10 +2066,10 @@ vbv_retry: · 136 unmodified lines
2066 pkt->duration = s->cur_pic.ptr->f->duration;2066 pkt->duration = s->cur_pic.ptr->f->duration;
2067 if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {2067 if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
2068 if (!s->cur_pic.ptr->coded_picture_number)2068 if (!s->cur_pic.ptr->coded_picture_number)
2069 pkt->dts = pkt->pts - s->dts_delta;2069 pkt->dts = pkt->pts - m->dts_delta;
2070 else2070 else
2071 pkt->dts = s->reordered_pts;2071 pkt->dts = m->reordered_pts;
2072 s->reordered_pts = pkt->pts;2072 m->reordered_pts = pkt->pts;
2073 } else2073 } else
2074 pkt->dts = pkt->pts;2074 pkt->dts = pkt->pts;
2075 2075
@@ -3882,7 +3882,7 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 1806 unmodified lines
3882 s->cur_pic.ptr->f->pict_type = s->pict_type;3882 s->cur_pic.ptr->f->pict_type = s->pict_type;
3883 3883
3884 if (s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY)3884 if (s->cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY)
3885 s->picture_in_gop_number=0;3885 m->picture_in_gop_number = 0;
3886 3886
3887 s->mb_x = s->mb_y = 0;3887 s->mb_x = s->mb_y = 0;
3888 s->last_bits= put_bits_count(&s->pb);3888 s->last_bits= put_bits_count(&s->pb);
@@ -3925,7 +3925,7 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 36 unmodified lines
3925 break;3925 break;
3926 case FMT_MPEG1:3926 case FMT_MPEG1:
3927 if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)3927 if (CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER)
3928 ff_mpeg1_encode_picture_header(s);3928 ff_mpeg1_encode_picture_header(m);
3929 break;3929 break;
3930 default:3930 default:
3931 av_assert0(0);3931 av_assert0(0);
libavcodec/mpegvideoenc.h+16−0
@@ -39,6 +39,22 @@ · 38 unmodified lines
39typedef struct MPVMainEncContext {39typedef struct MPVMainEncContext {
40 MpegEncContext s; ///< The main slicecontext40 MpegEncContext s; ///< The main slicecontext
41 41
42 int intra_only; ///< if true, only intra pictures are generated
43 int gop_size;
44 int picture_in_gop_number; ///< 0-> first pic in gop, ...
45 int input_picture_number; ///< used to set pic->display_picture_number
46 int coded_picture_number; ///< used to set pic->coded_picture_number
47
48 int64_t user_specified_pts; ///< last non-zero pts from user-supplied AVFrame
49 /**
50 * pts difference between the first and second input frame, used for
51 * calculating dts of the first frame when there's a delay */
52 int64_t dts_delta;
53 /**
54 * reordered pts to be used as dts for the next output frame when there's
55 * a delay */
56 int64_t reordered_pts;
57
42 /// temporary frames used by b_frame_strategy = 258 /// temporary frames used by b_frame_strategy = 2
43 AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2];59 AVFrame *tmp_frames[MPVENC_MAX_B_FRAMES + 2];
44 int b_frame_strategy;60 int b_frame_strategy;
libavcodec/ratecontrol.c+2−2
@@ -660,7 +660,7 @@ av_cold int ff_rate_control_init(MPVMainEncContext *const m) · 659 unmodified lines
660 double bits = rcc->initial_cplx * (i / 10000.0 + 1.0) * s->mb_num;660 double bits = rcc->initial_cplx * (i / 10000.0 + 1.0) * s->mb_num;
661 RateControlEntry rce;661 RateControlEntry rce;
662 662
663 if (i % ((s->gop_size + 3) / 4) == 0)663 if (i % ((m->gop_size + 3) / 4) == 0)
664 rce.pict_type = AV_PICTURE_TYPE_I;664 rce.pict_type = AV_PICTURE_TYPE_I;
665 else if (i % (s->max_b_frames + 1))665 else if (i % (s->max_b_frames + 1))
666 rce.pict_type = AV_PICTURE_TYPE_B;666 rce.pict_type = AV_PICTURE_TYPE_B;
@@ -1033,7 +1033,7 @@ float ff_rate_estimate_qscale(MPVMainEncContext *const m, int dry_run) · 366 unmodified lines
1033 av_assert0(q > 0.0);1033 av_assert0(q > 0.0);
1034 1034
1035 // FIXME type dependent blur like in 2-pass1035 // FIXME type dependent blur like in 2-pass
1036 if (pict_type == AV_PICTURE_TYPE_P || s->intra_only) {1036 if (pict_type == AV_PICTURE_TYPE_P || m->intra_only) {
1037 rcc->short_term_qsum *= a->qblur;1037 rcc->short_term_qsum *= a->qblur;
1038 rcc->short_term_qcount *= a->qblur;1038 rcc->short_term_qcount *= a->qblur;
1039 1039

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