gpt4 book ai didi

android - 在 4.2 Jelly Bean 模拟器和 nexus 4 设备上使用 mediacodec api 的不同结果

转载 作者:行者123 更新时间:2023-11-29 01:55:05 24 4
gpt4 key购买 nike

我正在使用新的 API MediaCodec。我想获取解码后的视频帧并在某个调度时间将它们呈现在表面上。现在我可以在模拟器上正确运行我的代码并获得如下视频帧格式:

{height=192, what=1869968451, color-format=19, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=320, crop-right=319}

但是当我在 nexus 4 上运行我的代码时,视频帧格式更改为

{height=180, what=1869968451, color-format=2141391875, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=384, crop-right=319}

我找不到颜色格式 2141391875 是什么以及为什么高度不是 192。一个有趣的问题是,当我从 codec.configure(format, surface/* surface */, null/* crypto */, 0/* flags */)codec.configure(format, null/* surface */, null/* crypto */, 0/* flags */) ,输出缓冲区长度将从0变为114688。但实际上,如果帧格式为YUV420p(320*192*1.5),正确的缓冲区长度应为92160。当我在模拟器上运行时,我发现在输出格式更改之前输出缓冲区已更改。但是当我在nexus 4上运行时并没有改变。日志如下所示,在模拟器上:

03-26 14:42:38.466: I/VideoPlayTAG(1212): count=0
03-26 14:42:38.476: I/VideoPlayTAG(1212): sampleSize:700
03-26 14:42:38.496: D/VideoPlayTAG(1212): next:true
03-26 14:42:38.496: I/VideoPlayTAG(1212): output index:-3
03-26 14:42:38.566: D/VideoPlayTAG(1212): output buffers have changed.
03-26 14:42:38.566: I/VideoPlayTAG(1212): count=1
03-26 14:42:38.566: I/VideoPlayTAG(1212): sampleSize:140
03-26 14:42:38.596: D/VideoPlayTAG(1212): next:true
03-26 14:42:38.596: I/VideoPlayTAG(1212): output index:-2
03-26 14:42:38.686: D/VideoPlayTAG(1212): color=19 width=320 height=192
03-26 14:42:38.686: I/JNI(1212): begin setRender 1734
03-26 14:42:38.686: I/JNI(1212): setRender
03-26 14:42:38.716: D/VideoPlayTAG(1212): output format has changed to {height=192, what=1869968451, color-format=19, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=320, crop-right=319}
03-26 14:42:38.716: I/VideoPlayTAG(1212): count=2

在连接 4 上:

03-26 10:17:59.674: I/VideoPlayTAG(29899): count=0
03-26 10:17:59.684: I/VideoPlayTAG(29899): sampleSize:700
03-26 10:17:59.684: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.694: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.694: I/VideoPlayTAG(29899): count=1
03-26 10:17:59.704: I/VideoPlayTAG(29899): sampleSize:140
03-26 10:17:59.704: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.704: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.714: I/VideoPlayTAG(29899): count=2
03-26 10:17:59.714: I/VideoPlayTAG(29899): sampleSize:131
03-26 10:17:59.714: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.724: I/VideoPlayTAG(29899): output index:-1
03-26 10:17:59.724: I/VideoPlayTAG(29899): count=3
03-26 10:17:59.724: I/VideoPlayTAG(29899): sampleSize:59
03-26 10:17:59.724: D/VideoPlayTAG(29899): next:true
03-26 10:17:59.724: I/VideoPlayTAG(29899): output index:-2
03-26 10:17:59.744: D/VideoPlayTAG(29899): color=2141391875 width=320 height=180
03-26 10:17:59.744: I/JNI(29899): begin setRender 1734
03-26 10:17:59.744: I/JNI(29899): setRender
03-26 10:17:59.744: D/VideoPlayTAG(29899): output format has changed to {height=180, what=1869968451, color-format=2141391875, slice-height=192, crop-left=0, width=320, crop-bottom=179, crop-top=0, mime=video/raw, stride=384, crop-right=319}
03-26 10:17:59.744: I/VideoPlayTAG(29899): count=4

谁能帮帮我?我发现问题可能是由于软件渲染和硬件渲染的不同造成的。

最佳答案

  1. 2141391875 (0x7fa30c03) 是 NV12 adreno 平铺(又名 HAL_PIXEL_FORMAT_NV12_ADRENO_TILED,又名 HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED)。这种颜色格式以硬件处理的最佳方式对像素数据进行排序。
  2. 模拟器中的图片高度也不是 192。请注意:上面写着“crop-bottom=179”。这意味着高度实际上是相同的 (180)。
  3. 114688 字节是缓冲区的合适大小。是这样计算的 = slice-height(192) * stride(384) * 1.5 对齐8K。
  4. INFO_OUTPUT_FORMAT_CHANGED 和 INFO_OUTPUT_BUFFERS_CHANGED 意义不同,顺序无关紧要。

还是没问题,一切正常。

关于android - 在 4.2 Jelly Bean 模拟器和 nexus 4 设备上使用 mediacodec api 的不同结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15650067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com