Skip to content

Commit bf54c21

Browse files
authored
Initialize dominant_ac also for ac_wrong_modifier erikkaashoek#161
1 parent fdf3a1c commit bf54c21

File tree

1 file changed

+105
-9
lines changed

1 file changed

+105
-9
lines changed

comskip.c

+105-9
Original file line numberDiff line numberDiff line change
@@ -4363,6 +4363,11 @@ bool BuildMasterCommList(void)
43634363
frame[frame_count].hasBright = 0;
43644364
InsertBlackFrame(frame_count,0,0,0, C_b);
43654365

4366+
if (cut_on_ac_change || ac_wrong_modifier != 0) {
4367+
FillACHistogram(true);
4368+
dominant_ac = ac_histogram[0].audio_channels;
4369+
}
4370+
43664371
if (cut_on_ac_change)
43674372
{
43684373
if (ac_block[ac_block_count].start > 0)
@@ -4372,9 +4377,6 @@ bool BuildMasterCommList(void)
43724377
ac_block_count++;
43734378
}
43744379

4375-
FillACHistogram(true);
4376-
dominant_ac = ac_histogram[0].audio_channels;
4377-
43784380
// Print out ar cblock list
43794381
Debug(4, "\nPrinting AC cblock list\n-----------------------------------------\n");
43804382
for (i = 0; i < ac_block_count; i++)
@@ -5506,6 +5508,33 @@ void WeighBlocks(void)
55065508
cblock[i].more |= C_AR;
55075509
}
55085510

5511+
5512+
/* Remove commercial blocks smaller than always_keep_first_seconds
5513+
so that delete_show_before_first_commercial will be able to remove
5514+
the previous show */
5515+
if (F2T(cblock[i].f_end) < always_keep_first_seconds)
5516+
{
5517+
Debug(2, "Block %i is shorter than %i seconds.\n", i, always_keep_first_seconds);
5518+
Debug(3, "Block %i score:\tBefore - %.2f\t", i, cblock[i].score);
5519+
cblock[i].score = 0;
5520+
cblock[i].cause |= C_H3;
5521+
cblock[i].cause |= C_H3;
5522+
Debug(3, "After - %.2f\n", cblock[i].score);
5523+
}
5524+
5525+
/* Remove commercial blocks smaller than always_keep_first_seconds
5526+
so that delete_show_after_last_commercial will be able to remove
5527+
the succeeding show */
5528+
if (F2L(cblock[block_count-1].f_end, cblock[i].f_start) < always_keep_last_seconds)
5529+
{
5530+
Debug(2, "Block %i is shorter than %i seconds.\n", i, always_keep_first_seconds);
5531+
Debug(3, "Block %i score:\tBefore - %.2f\t", i, cblock[i].score);
5532+
cblock[i].score = 0;
5533+
cblock[i].cause |= C_H3;
5534+
cblock[i].cause |= C_H3;
5535+
Debug(3, "After - %.2f\n", cblock[i].score);
5536+
}
5537+
55095538

55105539
}
55115540

@@ -7418,6 +7447,8 @@ bool OutputBlocks(void)
74187447
deleted = true;
74197448
}
74207449
}
7450+
7451+
/*
74217452
#ifdef NOTDEF
74227453
// keep first seconds
74237454
if (always_keep_first_seconds && commercial_count >= 0)
@@ -7463,6 +7494,7 @@ bool OutputBlocks(void)
74637494
}
74647495
}
74657496
#endif
7497+
*/
74667498

74677499
/*
74687500
// Delete too short first commercial
@@ -7556,22 +7588,85 @@ bool OutputBlocks(void)
75567588

75577589
if (delete_show_before_first_commercial &&
75587590
commercial_count > -1 &&
7559-
commercial[0].start_block == 1 &&
7591+
//commercial[0].start_block == 1 &&
75607592
((delete_show_before_first_commercial == 1 && cblock[commercial[0].end_block].f_end < after_start) ||
75617593
(delete_show_before_first_commercial > F2T(cblock[commercial[0].end_block].f_end)))
75627594
)
75637595
{
7596+
i = commercial[0].start_block;
75647597
commercial[0].start_block = 0;
75657598
commercial[0].start_frame = cblock[0].f_start/* + (cblock[i + 1].bframe_count / 2)*/;
75667599
commercial[0].length = F2L(commercial[0].end_frame, commercial[0].start_frame);
7567-
Debug(3, "H5 Deleting cblock %i of %i seconds because it comes before the first commercial.\n",
7568-
0, (int)cblock[0].length);
7569-
cblock[0].score = 99.99;
7570-
cblock[0].cause |= C_H5;
7571-
cblock[0].more |= C_H5;
7600+
while (i > 0)
7601+
{
7602+
Debug(3, "H5 Deleting cblock %i of %i seconds because it comes before the first commercial.\n",
7603+
i, (int)cblock[i].length);
7604+
cblock[i].score = 99.99;
7605+
cblock[i].cause |= C_H5;
7606+
cblock[i].more |= C_H5;
7607+
i--;
7608+
}
75727609

75737610
}
75747611

7612+
/* Delete shows that come before and after the current show if
7613+
the are seperated by a short commercial, shorter than min_commercialbreak
7614+
and only if the shows are shorter than added_recording or the specified
7615+
duration */
7616+
if (delete_show_before_or_after_current &&
7617+
commercial_count > -1)
7618+
{
7619+
if (((delete_show_before_or_after_current == 1 && commercial[0].start_frame < after_start) ||
7620+
(delete_show_before_or_after_current > 1 && commercial[0].start_frame < delete_show_before_or_after_current)) &&
7621+
(commercial[0].length < min_commercialbreak))
7622+
{
7623+
i = commercial[0].start_block - 1;
7624+
commercial[0].start_block = 0;
7625+
commercial[0].start_frame = cblock[0].f_start;
7626+
commercial[0].length = F2L(commercial[0].end_frame, commercial[0].start_frame);
7627+
while (i > 0)
7628+
{
7629+
Debug(3, "H5 Deleting cblock %i of %i seconds because it comes before a short first commercial.\n",
7630+
i, (int)cblock[i].length);
7631+
cblock[i].score = 99.99;
7632+
cblock[i].cause |= C_H5;
7633+
cblock[i].more |= C_H5;
7634+
i--;
7635+
}
7636+
}
7637+
7638+
k = commercial_count;
7639+
int j = block_count - 1;
7640+
if (commercial[k].length < min_commercialbreak)
7641+
{
7642+
i = commercial[k].end_block + 1;
7643+
int combined_length = 0;
7644+
while (i < j)
7645+
{
7646+
combined_length += cblock[i].length;
7647+
i++;
7648+
}
7649+
if ((delete_show_before_or_after_current == 1 && combined_length < after_start) ||
7650+
(delete_show_before_or_after_current > 1 && combined_length < delete_show_before_or_after_current))
7651+
{
7652+
i = commercial[k].start_block + 1;
7653+
commercial[k].end_block = j;
7654+
commercial[k].end_frame = cblock[j].f_end;
7655+
commercial[k].length = F2L(commercial[k].end_frame, commercial[k].start_frame);
7656+
while (i < j)
7657+
{
7658+
Debug(3, "H5 Deleting cblock %i of %i seconds because it comes after a short last commercial.\n",
7659+
i, (int)cblock[i].length);
7660+
cblock[i].score = 99.99;
7661+
cblock[i].cause |= C_H5;
7662+
cblock[i].more |= C_H5;
7663+
i++;
7664+
}
7665+
}
7666+
}
7667+
}
7668+
7669+
/*
75757670
// keep first seconds
75767671
if (always_keep_first_seconds && commercial_count >= 0)
75777672
{
@@ -7614,6 +7709,7 @@ bool OutputBlocks(void)
76147709
commercial[k].end_frame--;
76157710
}
76167711
}
7712+
*/
76177713

76187714

76197715

0 commit comments

Comments
 (0)