Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f26a198 authored by Ray Essick's avatar Ray Essick
Browse files

Define MediaFormat crop-related constants

MediaFormat used literals "crop-left", "crop-right", crop-bottom
and crop-top. Define appropriate MediaFormat.KEY_XXX for these.

Bug: 178687730
Test: build, boot
Test: atest android.media.codec.cts.EncodeDecodeTest
Change-Id: I1782caa5ff320d3dca19272c5532466199ef72f0
parent dccf3ec6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -22195,6 +22195,10 @@ package android.media {
    field public static final String KEY_COLOR_TRANSFER_REQUEST = "color-transfer-request";
    field public static final String KEY_COMPLEXITY = "complexity";
    field public static final String KEY_CREATE_INPUT_SURFACE_SUSPENDED = "create-input-buffers-suspended";
    field public static final String KEY_CROP_BOTTOM = "crop-bottom";
    field public static final String KEY_CROP_LEFT = "crop-left";
    field public static final String KEY_CROP_RIGHT = "crop-right";
    field public static final String KEY_CROP_TOP = "crop-top";
    field public static final String KEY_DURATION = "durationUs";
    field public static final String KEY_ENCODER_DELAY = "encoder-delay";
    field public static final String KEY_ENCODER_PADDING = "encoder-padding";
+12 −8
Original line number Diff line number Diff line
@@ -223,19 +223,19 @@ import java.util.concurrent.locks.ReentrantLock;
  </thead>
  <tbody>
   <tr>
    <td>{@code "crop-left"}</td>
    <td>{@link MediaFormat#KEY_CROP_LEFT}</td>
    <td>Integer</td>
    <td>The left-coordinate (x) of the crop rectangle</td>
   </tr><tr>
    <td>{@code "crop-top"}</td>
    <td>{@link MediaFormat#KEY_CROP_TOP}</td>
    <td>Integer</td>
    <td>The top-coordinate (y) of the crop rectangle</td>
   </tr><tr>
    <td>{@code "crop-right"}</td>
    <td>{@link MediaFormat#KEY_CROP_RIGHT}</td>
    <td>Integer</td>
    <td>The right-coordinate (x) <strong>MINUS 1</strong> of the crop rectangle</td>
   </tr><tr>
    <td>{@code "crop-bottom"}</td>
    <td>{@link MediaFormat#KEY_CROP_BOTTOM}</td>
    <td>Integer</td>
    <td>The bottom-coordinate (y) <strong>MINUS 1</strong> of the crop rectangle</td>
   </tr><tr>
@@ -251,12 +251,16 @@ import java.util.concurrent.locks.ReentrantLock;
 <pre class=prettyprint>
 MediaFormat format = decoder.getOutputFormat(&hellip;);
 int width = format.getInteger(MediaFormat.KEY_WIDTH);
 if (format.containsKey("crop-left") && format.containsKey("crop-right")) {
     width = format.getInteger("crop-right") + 1 - format.getInteger("crop-left");
 if (format.containsKey(MediaFormat.KEY_CROP_LEFT)
         && format.containsKey(MediaFormat.KEY_CROP_RIGHT)) {
     width = format.getInteger(MediaFormat.KEY_CROP_RIGHT) + 1
                 - format.getInteger(MediaFormat.KEY_CROP_LEFT);
 }
 int height = format.getInteger(MediaFormat.KEY_HEIGHT);
 if (format.containsKey("crop-top") && format.containsKey("crop-bottom")) {
     height = format.getInteger("crop-bottom") + 1 - format.getInteger("crop-top");
 if (format.containsKey(MediaFormat.KEY_CROP_TOP)
         && format.containsKey(MediaFormat.KEY_CROP_BOTTOM)) {
     height = format.getInteger(MediaFormat.KEY_CROP_BOTTOM) + 1
                  - format.getInteger(MediaFormat.KEY_CROP_TOP);
 }
 </pre>
 <p class=note>
+36 −0
Original line number Diff line number Diff line
@@ -358,6 +358,42 @@ public final class MediaFormat {
     */
    public static final String KEY_HEIGHT = "height";

    /**
     * A key describing the bottom-coordinate (y) of the crop rectangle.
     * This is the bottom-most row included in the crop frame,
     * where row indices start at 0.
     * Additional information on the crop rectangle semantics can be found at
     * {@link android.media.MediaCodec}.
     */
    public static final String KEY_CROP_BOTTOM = "crop-bottom";

    /**
     * A key describing the left-coordinate (x) of the crop rectangle.
     * This is the left-most column included in the crop frame,
     * where column indices start at 0.
     * Additional information on the crop rectangle semantics can be found at
     * {@link android.media.MediaCodec}.
     */
    public static final String KEY_CROP_LEFT = "crop-left";

    /**
     * A key describing the right-coordinate (x) of the crop rectangle.
     * This is the right-most column included in the crop frame,
     * where column indices start at 0.
     * Additional information on the crop rectangle semantics can be found at
     * {@link android.media.MediaCodec}.
     */
    public static final String KEY_CROP_RIGHT = "crop-right";

    /**
     * A key describing the top-coordinate (y) of the crop rectangle.
     * This is the top-most row included in the crop frame,
     * where row indices start at 0.
     * Additional information on the crop rectangle semantics can be found at
     * {@link android.media.MediaCodec}.
     */
    public static final String KEY_CROP_TOP = "crop-top";

    /**
     * A key describing the maximum expected width of the content in a video
     * decoder format, in case there are resolution changes in the video content.