@@ -4363,6 +4363,11 @@ bool BuildMasterCommList(void)
4363
4363
frame[frame_count].hasBright = 0;
4364
4364
InsertBlackFrame(frame_count,0,0,0, C_b);
4365
4365
4366
+ if (cut_on_ac_change || ac_wrong_modifier != 0) {
4367
+ FillACHistogram(true);
4368
+ dominant_ac = ac_histogram[0].audio_channels;
4369
+ }
4370
+
4366
4371
if (cut_on_ac_change)
4367
4372
{
4368
4373
if (ac_block[ac_block_count].start > 0)
@@ -4372,9 +4377,6 @@ bool BuildMasterCommList(void)
4372
4377
ac_block_count++;
4373
4378
}
4374
4379
4375
- FillACHistogram(true);
4376
- dominant_ac = ac_histogram[0].audio_channels;
4377
-
4378
4380
// Print out ar cblock list
4379
4381
Debug(4, "\nPrinting AC cblock list\n-----------------------------------------\n");
4380
4382
for (i = 0; i < ac_block_count; i++)
@@ -5506,6 +5508,33 @@ void WeighBlocks(void)
5506
5508
cblock[i].more |= C_AR;
5507
5509
}
5508
5510
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
+
5509
5538
5510
5539
}
5511
5540
@@ -7418,6 +7447,8 @@ bool OutputBlocks(void)
7418
7447
deleted = true;
7419
7448
}
7420
7449
}
7450
+
7451
+ /*
7421
7452
#ifdef NOTDEF
7422
7453
// keep first seconds
7423
7454
if (always_keep_first_seconds && commercial_count >= 0)
@@ -7463,6 +7494,7 @@ bool OutputBlocks(void)
7463
7494
}
7464
7495
}
7465
7496
#endif
7497
+ */
7466
7498
7467
7499
/*
7468
7500
// Delete too short first commercial
@@ -7556,22 +7588,85 @@ bool OutputBlocks(void)
7556
7588
7557
7589
if (delete_show_before_first_commercial &&
7558
7590
commercial_count > -1 &&
7559
- commercial[0].start_block == 1 &&
7591
+ // commercial[0].start_block == 1 &&
7560
7592
((delete_show_before_first_commercial == 1 && cblock[commercial[0].end_block].f_end < after_start) ||
7561
7593
(delete_show_before_first_commercial > F2T(cblock[commercial[0].end_block].f_end)))
7562
7594
)
7563
7595
{
7596
+ i = commercial[0].start_block;
7564
7597
commercial[0].start_block = 0;
7565
7598
commercial[0].start_frame = cblock[0].f_start/* + (cblock[i + 1].bframe_count / 2)*/;
7566
7599
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
+ }
7572
7609
7573
7610
}
7574
7611
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
+ /*
7575
7670
// keep first seconds
7576
7671
if (always_keep_first_seconds && commercial_count >= 0)
7577
7672
{
@@ -7614,6 +7709,7 @@ bool OutputBlocks(void)
7614
7709
commercial[k].end_frame--;
7615
7710
}
7616
7711
}
7712
+ */
7617
7713
7618
7714
7619
7715
0 commit comments