Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java

Issue 1270403007: Revert H.264 HW encoder setting to CBR mode. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Log.d(TAG, "Java initEncode: " + type + " : " + width + " x " + height + 211 Log.d(TAG, "Java initEncode: " + type + " : " + width + " x " + height +
212 ". @ " + kbps + " kbps. Fps: " + fps + 212 ". @ " + kbps + " kbps. Fps: " + fps +
213 ". Color: 0x" + Integer.toHexString(colorFormat)); 213 ". Color: 0x" + Integer.toHexString(colorFormat));
214 if (mediaCodecThread != null) { 214 if (mediaCodecThread != null) {
215 throw new RuntimeException("Forgot to release()?"); 215 throw new RuntimeException("Forgot to release()?");
216 } 216 }
217 this.type = type; 217 this.type = type;
218 EncoderProperties properties = null; 218 EncoderProperties properties = null;
219 String mime = null; 219 String mime = null;
220 int keyFrameIntervalSec = 0; 220 int keyFrameIntervalSec = 0;
221 int bitrateMode = 0;
222 if (type == VideoCodecType.VIDEO_CODEC_VP8) { 221 if (type == VideoCodecType.VIDEO_CODEC_VP8) {
223 mime = VP8_MIME_TYPE; 222 mime = VP8_MIME_TYPE;
224 properties = findHwEncoder(VP8_MIME_TYPE, supportedVp8HwCodecPrefixes); 223 properties = findHwEncoder(VP8_MIME_TYPE, supportedVp8HwCodecPrefixes);
225 keyFrameIntervalSec = 100; 224 keyFrameIntervalSec = 100;
226 bitrateMode = VIDEO_ControlRateConstant;
227 } else if (type == VideoCodecType.VIDEO_CODEC_H264) { 225 } else if (type == VideoCodecType.VIDEO_CODEC_H264) {
228 mime = H264_MIME_TYPE; 226 mime = H264_MIME_TYPE;
229 properties = findHwEncoder(H264_MIME_TYPE, supportedH264HwCodecPrefixes); 227 properties = findHwEncoder(H264_MIME_TYPE, supportedH264HwCodecPrefixes);
230 bitrateMode = VIDEO_ControlRateVariable;
231 keyFrameIntervalSec = 20; 228 keyFrameIntervalSec = 20;
232 } 229 }
233 if (properties == null) { 230 if (properties == null) {
234 throw new RuntimeException("Can not find HW encoder for " + type); 231 throw new RuntimeException("Can not find HW encoder for " + type);
235 } 232 }
236 mediaCodecThread = Thread.currentThread(); 233 mediaCodecThread = Thread.currentThread();
237 try { 234 try {
238 MediaFormat format = MediaFormat.createVideoFormat(mime, width, height); 235 MediaFormat format = MediaFormat.createVideoFormat(mime, width, height);
239 format.setInteger(MediaFormat.KEY_BIT_RATE, 1000 * kbps); 236 format.setInteger(MediaFormat.KEY_BIT_RATE, 1000 * kbps);
240 format.setInteger("bitrate-mode", bitrateMode); 237 format.setInteger("bitrate-mode", VIDEO_ControlRateConstant);
241 format.setInteger(MediaFormat.KEY_COLOR_FORMAT, properties.colorFormat); 238 format.setInteger(MediaFormat.KEY_COLOR_FORMAT, properties.colorFormat);
242 format.setInteger(MediaFormat.KEY_FRAME_RATE, fps); 239 format.setInteger(MediaFormat.KEY_FRAME_RATE, fps);
243 format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, keyFrameIntervalSec); 240 format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, keyFrameIntervalSec);
244 Log.d(TAG, " Format: " + format); 241 Log.d(TAG, " Format: " + format);
245 mediaCodec = createByCodecName(properties.codecName); 242 mediaCodec = createByCodecName(properties.codecName);
246 if (mediaCodec == null) { 243 if (mediaCodec == null) {
247 return null; 244 return null;
248 } 245 }
249 mediaCodec.configure( 246 mediaCodec.configure(
250 format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); 247 format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 checkOnMediaCodecThread(); 416 checkOnMediaCodecThread();
420 try { 417 try {
421 mediaCodec.releaseOutputBuffer(index, false); 418 mediaCodec.releaseOutputBuffer(index, false);
422 return true; 419 return true;
423 } catch (IllegalStateException e) { 420 } catch (IllegalStateException e) {
424 Log.e(TAG, "releaseOutputBuffer failed", e); 421 Log.e(TAG, "releaseOutputBuffer failed", e);
425 return false; 422 return false;
426 } 423 }
427 } 424 }
428 } 425 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698