Hi,
On Sat, Dec 24, 2011 at 3:34 PM, Ronald S. Bultje <[email protected]>wrote:
> That's until line 1024.
>
[..]
> @@ -1024,39 +1053,39 @@ static int estimate_best_b_count(MpegEncContext
*s){
[..]
> + input[0].pict_type = AV_PICTURE_TYPE_I;
> + input[0].quality = 1 * FF_QP2LAMBDA;
> out_size = avcodec_encode_video(c, outbuf, outbuf_size,
&input[0]);
> // rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
use:
{
uncommented code
// commented code
}
not:
{
uncommented code
// commented code
}
> + for (i = 0; i < s->max_b_frames + 1; i++) {
> + int is_p = i % (j + 1) == j || i == s->max_b_frames;
>
> + input[i + 1].pict_type = is_p ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_B;
> + input[i + 1].quality = is_p ? p_lambda : b_lambda;
Vertically align '='. Also >80 characters.
> +static int select_input_picture(MpegEncContext *s)
[..]
> + if (s->reordered_input_picture[0] == NULL && s->input_picture[0]) {
> + if (/*s->picture_in_gop_number >= s->gop_size ||*/
s->next_picture_ptr == NULL || s->intra_only) {
> + s->reordered_input_picture[0] = s->input_picture[0];
> s->reordered_input_picture[0]->f.pict_type =
AV_PICTURE_TYPE_I;
> s->reordered_input_picture[0]->f.coded_picture_number =
s->coded_picture_number++;
> + } else {
>80 characters.
> + if (s->avctx->frame_skip_threshold ||
s->avctx->frame_skip_factor) {
> + if (s->picture_in_gop_number < s->gop_size &&
skip_check(s, s->input_picture[0], s->next_picture_ptr)) {
> //FIXME check that te gop check above is +-1 correct
> //av_log(NULL, AV_LOG_DEBUG, "skip %p %"PRId64"\n",
s->input_picture[0]->f.data[0], s->input_picture[0]->pts);
>80 characters, and commented code intending.
> + } else {
> assert( s->input_picture[0]->f.type ==
FF_BUFFER_TYPE_USER
> || s->input_picture[0]->f.type ==
FF_BUFFER_TYPE_INTERNAL);
|| on previous line, and >80 characters.
> @@ -1110,13 +1140,13 @@ static int select_input_picture(MpegEncContext
*s){
[..]
> int pict_num =
s->input_picture[0]->f.display_picture_number + i;
80 characters.
> + if (!s->input_picture[i]) {
> s->rc_context.entry[pict_num-1].new_pict_type =
AV_PICTURE_TYPE_P;
> break;
> }
>80 characters.
> @@ -1126,32 +1156,34 @@ static int select_input_picture(MpegEncContext
*s){
[..]
> + } else if (s->avctx->b_frame_strategy == 1) {
> + for (i = 1; i < s->max_b_frames + 1; i++) {
> + if (s->input_picture[i] &&
s->input_picture[i]->b_frame_score == 0) {
>80 characters.
> + s->input_picture[i]->b_frame_score =
> + get_intra_count(s, s->input_picture[i
]->f.data[0],
> + s->input_picture[i -
1]->f.data[0], s->linesize) + 1;
>80 characters. The indenting is kind of weird but that's OK for vertical
alignment purposes.
> + for (i = 0; i < s->max_b_frames + 1; i++) {
> + if (s->input_picture[i] == NULL ||
s->input_picture[i]->b_frame_score - 1 > s->mb_num /
s->avctx->b_sensitivity)
> + break;
> }
>80 characters.
> @@ -1159,35 +1191,35 @@ static int select_input_picture(MpegEncContext
*s){
> //b_count+= b_frames;
> //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count);
Commented code indenting.
> + if (s->input_picture[b_frames]->f.pict_type ==
AV_PICTURE_TYPE_B && b_frames == s->max_b_frames) {
> av_log(s->avctx, AV_LOG_ERROR, "warning, too many b
frames in a row\n");
> }
>80 characters.
> + if (s->picture_in_gop_number + b_frames >= s->gop_size) {
> + if ((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size >
s->picture_in_gop_number) {
> + b_frames = s->gop_size - s->picture_in_gop_number -
1;
> + } else {
> + if (s->flags & CODEC_FLAG_CLOSED_GOP)
> + b_frames = 0;
> s->input_picture[b_frames]->f.pict_type =
AV_PICTURE_TYPE_I;
> }
> }
>80 characters, and indenting should increase by 4 spaces per level, not 2.
> - if( (s->flags & CODEC_FLAG_CLOSED_GOP)
> + if ( (s->flags & CODEC_FLAG_CLOSED_GOP)
> && b_frames
> - && s->input_picture[b_frames]->f.pict_type==
AV_PICTURE_TYPE_I)
> + && s->input_picture[b_frames]->f.pict_type ==
AV_PICTURE_TYPE_I)
> b_frames--;
&& goes on previous line. First line should not have a space between the
two "("s.
> - s->reordered_input_picture[0]= s->input_picture[b_frames];
> + s->reordered_input_picture[0] = s->input_picture[b_frames];
> if (s->reordered_input_picture[0]->f.pict_type !=
AV_PICTURE_TYPE_I)
> s->reordered_input_picture[0]->f.pict_type =
AV_PICTURE_TYPE_P;
> s->reordered_input_picture[0]->f.coded_picture_number =
s->coded_picture_number++;
>80 characters.
> - for(i=0; i<b_frames; i++){
> + for (i = 0; i < b_frames; i++) {
> s->reordered_input_picture[i + 1] = s->input_picture[i];
> s->reordered_input_picture[i + 1]->f.pict_type =
AV_PICTURE_TYPE_B;
>80 characters.
> s->reordered_input_picture[i +
1]->f.coded_picture_number = s->coded_picture_number++;
>80 characters.
> @@ -1195,7 +1227,7 @@ static int select_input_picture(MpegEncContext *s){
[..]
> + if (s->reordered_input_picture[0]) {
> s->reordered_input_picture[0]->f.reference =
s->reordered_input_picture[0]->f.pict_type!=AV_PICTURE_TYPE_B ? 3 : 0;
>80 characters.
> @@ -1203,34 +1235,34 @@ no_output_pic:
[..]
> if (s->reordered_input_picture[0]->f.type ==
FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size) {
> // input is a shared pix, so we can't modifiy it -> alloc a
new one & ensure that the shared one is reuseable
>80 characters for both lines.
> /* mark us unused / free shared pic */
> if (s->reordered_input_picture[0]->f.type ==
FF_BUFFER_TYPE_INTERNAL)
> s->avctx->release_buffer(s->avctx,
(AVFrame*)s->reordered_input_picture[0]);
>80 characters.
> copy_picture_attributes(s, (AVFrame*)pic,
(AVFrame*)s->reordered_input_picture[0]);
Same.
> assert( s->reordered_input_picture[0]->f.type ==
FF_BUFFER_TYPE_USER
> || s->reordered_input_picture[0]->f.type ==
FF_BUFFER_TYPE_INTERNAL);
|| should go on previous line, and no spaces between opening ( and s->...
> @@ -1238,7 +1270,7 @@ no_output_pic:
[..]
> s->picture_number = s->new_picture.f.display_picture_number;
> //printf("dpn:%d\n", s->picture_number);
Commented code indenting.
> @@ -1248,25 +1280,25 @@ int MPV_encode_picture(AVCodecContext *avctx,
[..]
> + for (i = 0; i < context_count; i++) {
> + int start_y = s->thread_context[i]->start_mb_y;
> + int end_y = s->thread_context[i]-> end_mb_y;
> + int h = s->mb_height;
> + uint8_t *start = buf + (size_t)(((int64_t) buf_size) * start_y /
h);
> + uint8_t *end = buf + (size_t)(((int64_t) buf_size) * end_y /
h);
Vertically align '='.
> @@ -1294,29 +1326,29 @@ vbv_retry:
[..]
> + if (put_bits_count(&s->pb) > max_size && s->lambda <
s->avctx->lmax) {
> + s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale);
>80 characters each.
> + for (i = 0; i < s->mb_height * s->mb_stride; i++)
> + s->lambda_table[i] = FFMAX(s->lambda_table[i] +
1, s->lambda_table[i] * (s->qscale + 1) / s->qscale);
>80 characters.
> + if (s->pict_type == AV_PICTURE_TYPE_P) { //done in
encode_picture() so we must undo it
> + if (s->flipflop_rounding || s->codec_id ==
CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
>80 characters.
> }
> // av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda);
> + for (i = 0; i < context_count; i++) {
Commented code indenting.
> @@ -1325,30 +1357,30 @@ vbv_retry:
[..]
> - if(s->flags&CODEC_FLAG_PASS1)
> + if (s->flags&CODEC_FLAG_PASS1)
> ff_write_pass1_stats(s);
Spaces arund &.
> + for (i = 0; i < 4; i++) {
> + s->current_picture_ptr->f.error[i] =
s->current_picture.f.error[i];
> avctx->error[i] +=
s->current_picture_ptr->f.error[i];
> }
>80 characters. You may be able to save this by removing some of the spaces.
> - if(s->flags&CODEC_FLAG_PASS1)
> + if (s->flags&CODEC_FLAG_PASS1)
> assert(avctx->header_bits + avctx->mv_bits +
avctx->misc_bits + avctx->i_tex_bits + avctx->p_tex_bits ==
put_bits_count(&s->pb));
>80 characters, spaces around '&'.
> + stuffing_count = ff_vbv_update(s, s->frame_bits);
> + if (stuffing_count) {
> + if (s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb) >>
3) < stuffing_count + 50) {
> av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n");
> return -1;
> }
>80 characters.
> @@ -1368,142 +1400,146 @@ vbv_retry:
[..]
> + if (s->avctx->rc_max_rate && s->avctx->rc_min_rate ==
s->avctx->rc_max_rate && s->out_format == FMT_MPEG1
> + && 90000LL * (avctx->rc_buffer_size - 1) <=
s->avctx->rc_max_rate * 0xFFFFLL) {
&& on previous line, >80 characters.
> + double inbits = s->avctx->rc_max_rate *
av_q2d(s->avctx->time_base);
> + int minbits = s->frame_bits - 8 * (s->vbv_delay_ptr -
s->pb.buf - 1);
> + double bits = s->rc_context.buffer_index + minbits -
inbits;
2 of the 3 here are >80 characters.
> + if (bits < 0)
> av_log(s->avctx, AV_LOG_ERROR, "Internal error, negative
bits\n");
>80 characters.
> + vbv_delay = bits * 90000
/ s->avctx->rc_max_rate;
> + min_delay = (minbits * 90000LL + s->avctx->rc_max_rate - 1)
/ s->avctx->rc_max_rate;
>80 characters.
> s->vbv_delay_ptr[0] &= 0xF8;
> + s->vbv_delay_ptr[0] |= vbv_delay >> 13;
> + s->vbv_delay_ptr[1] = vbv_delay >> 5;
> s->vbv_delay_ptr[2] &= 0x07;
> + s->vbv_delay_ptr[2] |= vbv_delay << 3;
> + avctx->vbv_delay = vbv_delay * 300;
Align '=' vertically for the last line.
> static inline void dct_single_coeff_elimination(MpegEncContext *s, int
n, int threshold)
>80 characters.
> + static const char tab[64] =
> + { 3, 2, 2, 1, 1, 1, 1, 1,
> + 1, 1, 1, 1, 1, 1, 1, 1,
> + 1, 1, 1, 1, 1, 1, 1, 1,
> + 0, 0, 0, 0, 0, 0, 0, 0,
> + 0, 0, 0, 0, 0, 0, 0, 0,
> + 0, 0, 0, 0, 0, 0, 0, 0,
> + 0, 0, 0, 0, 0, 0, 0, 0,
> + 0, 0, 0, 0, 0, 0, 0, 0 };
{ goes on opening line for tables, i.e.
static const char tab[64] = {
3, 2, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, ...
};
> /* Are all we could set to zero already zero? */
> - if(last_index<=skip_dc - 1) return;
> + if (last_index <= skip_dc - 1) return;
return goes on its on line.
> static inline void clip_coeffs(MpegEncContext *s, DCTELEM *block, int
last_index)
[..]
> - if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE)
> + if (overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE)
> av_log(s->avctx, AV_LOG_INFO, "warning, clipping %d dct
coefficients to %d..%d\n", overflow, minlevel, maxlevel);
>80 characters.
> +static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride)
[..]
> int x, y;
> //FIXME optimize
Wrongly indented comment.
Until line 1512.
Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel