Fix TTML bitmap subtitles
+ Use start for anchoring, instead of center. + Add the height to the TTML bitmap cue rendering layout. Issue:#5633 PiperOrigin-RevId: 250519710
This commit is contained in:
parent
082aee692b
commit
9da9941e38
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
### 2.10.2 ###
|
### 2.10.2 ###
|
||||||
|
|
||||||
|
* Subtitles:
|
||||||
|
* TTML: Fix bitmap rendering
|
||||||
|
([#5633](https://github.com/google/ExoPlayer/pull/5633)).
|
||||||
* UI:
|
* UI:
|
||||||
* Allow setting `DefaultTimeBar` attributes on `PlayerView` and
|
* Allow setting `DefaultTimeBar` attributes on `PlayerView` and
|
||||||
`PlayerControlView`.
|
`PlayerControlView`.
|
||||||
|
@ -429,6 +429,7 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
|
|||||||
/* lineType= */ Cue.LINE_TYPE_FRACTION,
|
/* lineType= */ Cue.LINE_TYPE_FRACTION,
|
||||||
lineAnchor,
|
lineAnchor,
|
||||||
width,
|
width,
|
||||||
|
height,
|
||||||
/* textSizeType= */ Cue.TEXT_SIZE_TYPE_FRACTIONAL_IGNORE_PADDING,
|
/* textSizeType= */ Cue.TEXT_SIZE_TYPE_FRACTIONAL_IGNORE_PADDING,
|
||||||
/* textSize= */ regionTextHeight);
|
/* textSize= */ regionTextHeight);
|
||||||
}
|
}
|
||||||
|
@ -231,11 +231,11 @@ import java.util.TreeSet;
|
|||||||
new Cue(
|
new Cue(
|
||||||
bitmap,
|
bitmap,
|
||||||
region.position,
|
region.position,
|
||||||
Cue.ANCHOR_TYPE_MIDDLE,
|
Cue.ANCHOR_TYPE_START,
|
||||||
region.line,
|
region.line,
|
||||||
region.lineAnchor,
|
region.lineAnchor,
|
||||||
region.width,
|
region.width,
|
||||||
/* height= */ Cue.DIMEN_UNSET));
|
region.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create text based cues.
|
// Create text based cues.
|
||||||
|
@ -28,6 +28,7 @@ import com.google.android.exoplayer2.text.Cue;
|
|||||||
public final @Cue.LineType int lineType;
|
public final @Cue.LineType int lineType;
|
||||||
public final @Cue.AnchorType int lineAnchor;
|
public final @Cue.AnchorType int lineAnchor;
|
||||||
public final float width;
|
public final float width;
|
||||||
|
public final float height;
|
||||||
public final @Cue.TextSizeType int textSizeType;
|
public final @Cue.TextSizeType int textSizeType;
|
||||||
public final float textSize;
|
public final float textSize;
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ import com.google.android.exoplayer2.text.Cue;
|
|||||||
/* lineType= */ Cue.TYPE_UNSET,
|
/* lineType= */ Cue.TYPE_UNSET,
|
||||||
/* lineAnchor= */ Cue.TYPE_UNSET,
|
/* lineAnchor= */ Cue.TYPE_UNSET,
|
||||||
/* width= */ Cue.DIMEN_UNSET,
|
/* width= */ Cue.DIMEN_UNSET,
|
||||||
|
/* height= */ Cue.DIMEN_UNSET,
|
||||||
/* textSizeType= */ Cue.TYPE_UNSET,
|
/* textSizeType= */ Cue.TYPE_UNSET,
|
||||||
/* textSize= */ Cue.DIMEN_UNSET);
|
/* textSize= */ Cue.DIMEN_UNSET);
|
||||||
}
|
}
|
||||||
@ -50,6 +52,7 @@ import com.google.android.exoplayer2.text.Cue;
|
|||||||
@Cue.LineType int lineType,
|
@Cue.LineType int lineType,
|
||||||
@Cue.AnchorType int lineAnchor,
|
@Cue.AnchorType int lineAnchor,
|
||||||
float width,
|
float width,
|
||||||
|
float height,
|
||||||
int textSizeType,
|
int textSizeType,
|
||||||
float textSize) {
|
float textSize) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -58,6 +61,7 @@ import com.google.android.exoplayer2.text.Cue;
|
|||||||
this.lineType = lineType;
|
this.lineType = lineType;
|
||||||
this.lineAnchor = lineAnchor;
|
this.lineAnchor = lineAnchor;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
this.textSizeType = textSizeType;
|
this.textSizeType = textSizeType;
|
||||||
this.textSize = textSize;
|
this.textSize = textSize;
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ public final class TtmlDecoderTest {
|
|||||||
assertThat(cue.position).isEqualTo(24f / 100f);
|
assertThat(cue.position).isEqualTo(24f / 100f);
|
||||||
assertThat(cue.line).isEqualTo(28f / 100f);
|
assertThat(cue.line).isEqualTo(28f / 100f);
|
||||||
assertThat(cue.size).isEqualTo(51f / 100f);
|
assertThat(cue.size).isEqualTo(51f / 100f);
|
||||||
assertThat(cue.bitmapHeight).isEqualTo(Cue.DIMEN_UNSET);
|
assertThat(cue.bitmapHeight).isEqualTo(12f / 100f);
|
||||||
|
|
||||||
cues = subtitle.getCues(4000000);
|
cues = subtitle.getCues(4000000);
|
||||||
assertThat(cues).hasSize(1);
|
assertThat(cues).hasSize(1);
|
||||||
@ -524,7 +524,7 @@ public final class TtmlDecoderTest {
|
|||||||
assertThat(cue.position).isEqualTo(21f / 100f);
|
assertThat(cue.position).isEqualTo(21f / 100f);
|
||||||
assertThat(cue.line).isEqualTo(35f / 100f);
|
assertThat(cue.line).isEqualTo(35f / 100f);
|
||||||
assertThat(cue.size).isEqualTo(57f / 100f);
|
assertThat(cue.size).isEqualTo(57f / 100f);
|
||||||
assertThat(cue.bitmapHeight).isEqualTo(Cue.DIMEN_UNSET);
|
assertThat(cue.bitmapHeight).isEqualTo(6f / 100f);
|
||||||
|
|
||||||
cues = subtitle.getCues(7500000);
|
cues = subtitle.getCues(7500000);
|
||||||
assertThat(cues).hasSize(1);
|
assertThat(cues).hasSize(1);
|
||||||
@ -534,7 +534,7 @@ public final class TtmlDecoderTest {
|
|||||||
assertThat(cue.position).isEqualTo(24f / 100f);
|
assertThat(cue.position).isEqualTo(24f / 100f);
|
||||||
assertThat(cue.line).isEqualTo(28f / 100f);
|
assertThat(cue.line).isEqualTo(28f / 100f);
|
||||||
assertThat(cue.size).isEqualTo(51f / 100f);
|
assertThat(cue.size).isEqualTo(51f / 100f);
|
||||||
assertThat(cue.bitmapHeight).isEqualTo(Cue.DIMEN_UNSET);
|
assertThat(cue.bitmapHeight).isEqualTo(12f / 100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -549,7 +549,7 @@ public final class TtmlDecoderTest {
|
|||||||
assertThat(cue.position).isEqualTo(307f / 1280f);
|
assertThat(cue.position).isEqualTo(307f / 1280f);
|
||||||
assertThat(cue.line).isEqualTo(562f / 720f);
|
assertThat(cue.line).isEqualTo(562f / 720f);
|
||||||
assertThat(cue.size).isEqualTo(653f / 1280f);
|
assertThat(cue.size).isEqualTo(653f / 1280f);
|
||||||
assertThat(cue.bitmapHeight).isEqualTo(Cue.DIMEN_UNSET);
|
assertThat(cue.bitmapHeight).isEqualTo(86f / 720f);
|
||||||
|
|
||||||
cues = subtitle.getCues(4000000);
|
cues = subtitle.getCues(4000000);
|
||||||
assertThat(cues).hasSize(1);
|
assertThat(cues).hasSize(1);
|
||||||
@ -559,7 +559,7 @@ public final class TtmlDecoderTest {
|
|||||||
assertThat(cue.position).isEqualTo(269f / 1280f);
|
assertThat(cue.position).isEqualTo(269f / 1280f);
|
||||||
assertThat(cue.line).isEqualTo(612f / 720f);
|
assertThat(cue.line).isEqualTo(612f / 720f);
|
||||||
assertThat(cue.size).isEqualTo(730f / 1280f);
|
assertThat(cue.size).isEqualTo(730f / 1280f);
|
||||||
assertThat(cue.bitmapHeight).isEqualTo(Cue.DIMEN_UNSET);
|
assertThat(cue.bitmapHeight).isEqualTo(43f / 720f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user