get source dimensions from plane stored in subs

This commit is contained in:
Drew Hill 2016-12-18 22:37:37 -05:00
parent 5d0501be82
commit 47d8b7ff16
2 changed files with 19 additions and 15 deletions

View File

@ -7,19 +7,25 @@ public class ImageCue extends Cue {
final private long start_display_time; final private long start_display_time;
final private int x; final private int x;
final private int y; final private int y;
final private int height; final private int bitmap_height;
final private int width; final private int bitmap_width;
final private int plane_height;
final private int plane_width;
final private Bitmap bitmap; final private Bitmap bitmap;
final private boolean isForced; final private boolean isForced;
public ImageCue(Bitmap bitmap, long start_display_time, int x, int y, int width, int height, boolean isForced) { public ImageCue(Bitmap bitmap, long start_display_time,
int x, int y, int bitmap_width, int bitmap_height, boolean isForced,
int plane_width, int plane_height) {
super(""); super("");
this.bitmap = bitmap; this.bitmap = bitmap;
this.start_display_time = start_display_time; this.start_display_time = start_display_time;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.width = width; this.bitmap_width = bitmap_width;
this.height = height; this.bitmap_height = bitmap_height;
this.plane_width = plane_width;
this.plane_height = plane_height;
this.isForced = isForced; this.isForced = isForced;
} }
@ -27,7 +33,9 @@ public class ImageCue extends Cue {
public Bitmap getBitmap() { return bitmap; } public Bitmap getBitmap() { return bitmap; }
public int getX() { return x; } public int getX() { return x; }
public int getY() { return y; } public int getY() { return y; }
public int getWidth() { return width; } public int getBitmapWidth() { return bitmap_width; }
public int getHeight() { return height; } public int getBitmapHeight() { return bitmap_height; }
public int getPlaneWidth() { return plane_width; }
public int getPlaneHeight() { return plane_height; }
public boolean isForcedSubtitle() { return isForced; } public boolean isForcedSubtitle() { return isForced; }
} }

View File

@ -614,10 +614,6 @@ public final class SimpleExoPlayerView extends FrameLayout {
private final class ComponentListener implements SimpleExoPlayer.VideoListener, private final class ComponentListener implements SimpleExoPlayer.VideoListener,
TextRenderer.Output, ExoPlayer.EventListener { TextRenderer.Output, ExoPlayer.EventListener {
private int sourceWidth = 0;
private int sourceHeight = 0;
// TextRenderer.Output implementation // TextRenderer.Output implementation
@Override @Override
@ -648,10 +644,12 @@ public final class SimpleExoPlayerView extends FrameLayout {
int surfaceAnchorY = (int) surfaceView.getY(); int surfaceAnchorY = (int) surfaceView.getY();
int surfaceWidth = surfaceView.getWidth(); int surfaceWidth = surfaceView.getWidth();
int surfaceHeight = surfaceView.getHeight(); int surfaceHeight = surfaceView.getHeight();
int sourceWidth = cue.getPlaneWidth();
int sourceHeight = cue.getPlaneHeight();
int subAnchorX = cue.getX(); int subAnchorX = cue.getX();
int subAnchorY = cue.getY(); int subAnchorY = cue.getY();
int subScaleWidth = cue.getWidth(); int subScaleWidth = cue.getBitmapWidth();
int subScaleHeight = cue.getHeight(); int subScaleHeight = cue.getBitmapHeight();
// they should change together as we keep the aspect ratio // they should change together as we keep the aspect ratio
if ((surfaceHeight != sourceHeight || surfaceWidth != sourceWidth) if ((surfaceHeight != sourceHeight || surfaceWidth != sourceWidth)
@ -691,8 +689,6 @@ public final class SimpleExoPlayerView extends FrameLayout {
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
float pixelWidthHeightRatio) { float pixelWidthHeightRatio) {
sourceWidth = width;
sourceHeight = height;
if (contentFrame != null) { if (contentFrame != null) {
float aspectRatio = height == 0 ? 1 : (width * pixelWidthHeightRatio) / height; float aspectRatio = height == 0 ? 1 : (width * pixelWidthHeightRatio) / height;
contentFrame.setAspectRatio(aspectRatio); contentFrame.setAspectRatio(aspectRatio);