translate the note of HardwareDecode into English

translate the note of HardwareDecode into English
pull/112/head
xufulong 5 years ago
parent d236171c01
commit 918fe2bc12
  1. 17
      app/src/main/java/com/frank/ffmpeg/hardware/HardwareDecode.java
  2. 2
      app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.java
  3. 2
      app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.java

@ -10,7 +10,7 @@ import android.view.Surface;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
* 使用MediaExtractor抽帧MediaCodec解码然后渲染到Surface * Extract by MediaExtractor, decode by MediaCodec, and render to Surface
* Created by frank on 2019/11/16. * Created by frank on 2019/11/16.
*/ */
@ -105,7 +105,8 @@ public class HardwareDecode {
} }
/** /**
* 根据原分辨率大小动态设置预览分辨率 * setting the preview resolution according to video aspect ratio
*
* @param mediaFormat mediaFormat * @param mediaFormat mediaFormat
*/ */
private void setPreviewRatio(MediaFormat mediaFormat) { private void setPreviewRatio(MediaFormat mediaFormat) {
@ -160,11 +161,11 @@ public class HardwareDecode {
} }
Log.i(TAG, "width=" + width + "--height=" + height + "--duration==" + duration); Log.i(TAG, "width=" + width + "--height=" + height + "--duration==" + duration);
//重新设置预览分辨率 //setting preview resolution
setPreviewRatio(mediaFormat); setPreviewRatio(mediaFormat);
Log.i(TAG, "mediaFormat=" + mediaFormat.toString()); Log.i(TAG, "mediaFormat=" + mediaFormat.toString());
//配置MediaCodec,并且start //config MediaCodec, and start
mediaCodec = MediaCodec.createDecoderByType(mimeType); mediaCodec = MediaCodec.createDecoderByType(mimeType);
mediaCodec.configure(mediaFormat, mSurface, null, 0); mediaCodec.configure(mediaFormat, mSurface, null, 0);
mediaCodec.start(); mediaCodec.start();
@ -176,12 +177,12 @@ public class HardwareDecode {
SystemClock.sleep(SLEEP_TIME); SystemClock.sleep(SLEEP_TIME);
continue; continue;
} }
//从缓冲区取出一个缓冲块,如果当前无可用缓冲块,返回inputIndex<0 //dequeue from input buffer
int inputIndex = mediaCodec.dequeueInputBuffer(DEQUEUE_TIME); int inputIndex = mediaCodec.dequeueInputBuffer(DEQUEUE_TIME);
if (inputIndex >= 0) { if (inputIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputIndex]; ByteBuffer inputBuffer = inputBuffers[inputIndex];
int sampleSize = mediaExtractor.readSampleData(inputBuffer, 0); int sampleSize = mediaExtractor.readSampleData(inputBuffer, 0);
//入队列 //enqueue to input buffer
if (sampleSize < 0) { if (sampleSize < 0) {
mediaCodec.queueInputBuffer(inputIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM); mediaCodec.queueInputBuffer(inputIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
} else { } else {
@ -190,7 +191,7 @@ public class HardwareDecode {
} }
} }
//出队列 //dequeue from output buffer
int outputIndex = mediaCodec.dequeueOutputBuffer(bufferInfo, DEQUEUE_TIME); int outputIndex = mediaCodec.dequeueOutputBuffer(bufferInfo, DEQUEUE_TIME);
switch (outputIndex) { switch (outputIndex) {
case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED: case MediaCodec.INFO_OUTPUT_FORMAT_CHANGED:
@ -203,7 +204,7 @@ public class HardwareDecode {
Log.i(TAG, "output buffer changed..."); Log.i(TAG, "output buffer changed...");
break; break;
default: default:
//渲染到surface //render to surface
mediaCodec.releaseOutputBuffer(outputIndex, true); mediaCodec.releaseOutputBuffer(outputIndex, true);
break; break;
} }

@ -1,7 +1,7 @@
package com.frank.ffmpeg.listener; package com.frank.ffmpeg.listener;
/** /**
* 流程执行监听器 * listener of FFmpeg processing
* Created by frank on 2019/11/11. * Created by frank on 2019/11/11.
*/ */
public interface OnHandleListener { public interface OnHandleListener {

@ -1,7 +1,7 @@
package com.frank.ffmpeg.listener; package com.frank.ffmpeg.listener;
/** /**
* RecyclerView item点击监听器 * listener of RecyclerView item clicking
* Created by frank on 2018/6/6. * Created by frank on 2018/6/6.
*/ */

Loading…
Cancel
Save