OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 DxDataIterator dec_iter = decoder_->GetDxData(); | 219 DxDataIterator dec_iter = decoder_->GetDxData(); |
220 while (dec_iter.Next() != NULL) { | 220 while (dec_iter.Next() != NULL) { |
221 ++received_frames; | 221 ++received_frames; |
222 } | 222 } |
223 } | 223 } |
224 EXPECT_EQ(decoded_frames, n); | 224 EXPECT_EQ(decoded_frames, n); |
225 EXPECT_EQ(received_frames, n); | 225 EXPECT_EQ(received_frames, n); |
226 } | 226 } |
227 | 227 |
228 void DropLayersAndMakeItVP9Comaptible(struct vpx_fixed_buf *const inputs, | 228 void DropEnhancementLayers(struct vpx_fixed_buf *const inputs, |
229 const int num_super_frames, | 229 const int num_super_frames, |
230 const int remained_spatial_layers, | 230 const int remained_spatial_layers) { |
231 const bool is_multiple_frame_contexts) { | |
232 ASSERT_TRUE(inputs != NULL); | 231 ASSERT_TRUE(inputs != NULL); |
233 ASSERT_GT(num_super_frames, 0); | 232 ASSERT_GT(num_super_frames, 0); |
234 ASSERT_GT(remained_spatial_layers, 0); | 233 ASSERT_GT(remained_spatial_layers, 0); |
235 | 234 |
236 for (int i = 0; i < num_super_frames; ++i) { | 235 for (int i = 0; i < num_super_frames; ++i) { |
237 uint32_t frame_sizes[8] = {0}; | 236 uint32_t frame_sizes[8] = {0}; |
238 int frame_count = 0; | 237 int frame_count = 0; |
239 int frames_found = 0; | 238 int frames_found = 0; |
240 int frame; | 239 int frame; |
241 ASSERT_TRUE(inputs[i].buf != NULL); | 240 ASSERT_TRUE(inputs[i].buf != NULL); |
242 ASSERT_GT(inputs[i].sz, 0U); | 241 ASSERT_GT(inputs[i].sz, 0U); |
243 | 242 |
244 vpx_codec_err_t res = | 243 vpx_codec_err_t res = |
245 vp9_parse_superframe_index(static_cast<const uint8_t*>(inputs[i].buf), | 244 vp9_parse_superframe_index(static_cast<const uint8_t*>(inputs[i].buf), |
246 inputs[i].sz, frame_sizes, &frame_count, | 245 inputs[i].sz, frame_sizes, &frame_count, |
247 NULL, NULL); | 246 NULL, NULL); |
248 ASSERT_EQ(VPX_CODEC_OK, res); | 247 ASSERT_EQ(VPX_CODEC_OK, res); |
249 | 248 |
250 if (frame_count == 0) { | 249 if (frame_count == 0) { |
251 // There's no super frame but only a single frame. | 250 // There's no super frame but only a single frame. |
252 ASSERT_EQ(1, remained_spatial_layers); | 251 ASSERT_EQ(1, remained_spatial_layers); |
253 if (is_multiple_frame_contexts) { | |
254 // Make a new super frame. | |
255 uint8_t marker = 0xc1; | |
256 unsigned int mask; | |
257 int mag; | |
258 | |
259 // Choose the magnitude. | |
260 for (mag = 0, mask = 0xff; mag < 4; ++mag) { | |
261 if (inputs[i].sz < mask) | |
262 break; | |
263 mask <<= 8; | |
264 mask |= 0xff; | |
265 } | |
266 marker |= mag << 3; | |
267 int index_sz = 2 + (mag + 1) * 2; | |
268 | |
269 inputs[i].buf = realloc(inputs[i].buf, inputs[i].sz + index_sz + 16); | |
270 ASSERT_TRUE(inputs[i].buf != NULL); | |
271 uint8_t *frame_data = static_cast<uint8_t*>(inputs[i].buf); | |
272 frame_data[0] &= ~2; // Set the show_frame flag to 0. | |
273 frame_data += inputs[i].sz; | |
274 // Add an one byte frame with show_existing_frame. | |
275 *frame_data++ = 0x88; | |
276 | |
277 // Write the super frame index. | |
278 *frame_data++ = marker; | |
279 | |
280 frame_sizes[0] = inputs[i].sz; | |
281 frame_sizes[1] = 1; | |
282 for (int j = 0; j < 2; ++j) { | |
283 unsigned int this_sz = frame_sizes[j]; | |
284 for (int k = 0; k <= mag; k++) { | |
285 *frame_data++ = this_sz & 0xff; | |
286 this_sz >>= 8; | |
287 } | |
288 } | |
289 *frame_data++ = marker; | |
290 inputs[i].sz += index_sz + 1; | |
291 } | |
292 } else { | 252 } else { |
293 // Found a super frame. | 253 // Found a super frame. |
294 uint8_t *frame_data = static_cast<uint8_t*>(inputs[i].buf); | 254 uint8_t *frame_data = static_cast<uint8_t*>(inputs[i].buf); |
295 uint8_t *frame_start = frame_data; | 255 uint8_t *frame_start = frame_data; |
296 for (frame = 0; frame < frame_count; ++frame) { | 256 for (frame = 0; frame < frame_count; ++frame) { |
297 // Looking for a visible frame. | 257 // Looking for a visible frame. |
298 if (frame_data[0] & 0x02) { | 258 if (frame_data[0] & 0x02) { |
299 ++frames_found; | 259 ++frames_found; |
300 if (frames_found == remained_spatial_layers) | 260 if (frames_found == remained_spatial_layers) |
301 break; | 261 break; |
302 } | 262 } |
303 frame_data += frame_sizes[frame]; | 263 frame_data += frame_sizes[frame]; |
304 } | 264 } |
305 ASSERT_LT(frame, frame_count) << "Couldn't find a visible frame. " | 265 ASSERT_LT(frame, frame_count) << "Couldn't find a visible frame. " |
306 << "remained_spatial_layers: " << remained_spatial_layers | 266 << "remained_spatial_layers: " << remained_spatial_layers |
307 << " super_frame: " << i | 267 << " super_frame: " << i; |
308 << " is_multiple_frame_context: " << is_multiple_frame_contexts; | 268 if (frame == frame_count - 1) |
309 if (frame == frame_count - 1 && !is_multiple_frame_contexts) | |
310 continue; | 269 continue; |
311 | 270 |
312 frame_data += frame_sizes[frame]; | 271 frame_data += frame_sizes[frame]; |
313 | 272 |
314 // We need to add one more frame for multiple frame contexts. | 273 // We need to add one more frame for multiple frame contexts. |
315 if (is_multiple_frame_contexts) | |
316 ++frame; | |
317 uint8_t marker = | 274 uint8_t marker = |
318 static_cast<const uint8_t*>(inputs[i].buf)[inputs[i].sz - 1]; | 275 static_cast<const uint8_t*>(inputs[i].buf)[inputs[i].sz - 1]; |
319 const uint32_t mag = ((marker >> 3) & 0x3) + 1; | 276 const uint32_t mag = ((marker >> 3) & 0x3) + 1; |
320 const size_t index_sz = 2 + mag * frame_count; | 277 const size_t index_sz = 2 + mag * frame_count; |
321 const size_t new_index_sz = 2 + mag * (frame + 1); | 278 const size_t new_index_sz = 2 + mag * (frame + 1); |
322 marker &= 0x0f8; | 279 marker &= 0x0f8; |
323 marker |= frame; | 280 marker |= frame; |
324 | 281 |
325 // Copy existing frame sizes. | 282 // Copy existing frame sizes. |
326 memmove(frame_data + (is_multiple_frame_contexts ? 2 : 1), | 283 memmove(frame_data + 1, frame_start + inputs[i].sz - index_sz + 1, |
327 frame_start + inputs[i].sz - index_sz + 1, new_index_sz - 2); | 284 new_index_sz - 2); |
328 if (is_multiple_frame_contexts) { | |
329 // Add a one byte frame with flag show_existing_frame. | |
330 *frame_data++ = 0x88 | (remained_spatial_layers - 1); | |
331 } | |
332 // New marker. | 285 // New marker. |
333 frame_data[0] = marker; | 286 frame_data[0] = marker; |
334 frame_data += (mag * (frame + 1) + 1); | 287 frame_data += (mag * (frame + 1) + 1); |
335 | 288 |
336 if (is_multiple_frame_contexts) { | |
337 // Write the frame size for the one byte frame. | |
338 frame_data -= mag; | |
339 *frame_data++ = 1; | |
340 for (uint32_t j = 1; j < mag; ++j) { | |
341 *frame_data++ = 0; | |
342 } | |
343 } | |
344 | |
345 *frame_data++ = marker; | 289 *frame_data++ = marker; |
346 inputs[i].sz = frame_data - frame_start; | 290 inputs[i].sz = frame_data - frame_start; |
347 | |
348 if (is_multiple_frame_contexts) { | |
349 // Change the show frame flag to 0 for all frames. | |
350 for (int j = 0; j < frame; ++j) { | |
351 frame_start[0] &= ~2; | |
352 frame_start += frame_sizes[j]; | |
353 } | |
354 } | |
355 } | 291 } |
356 } | 292 } |
357 } | 293 } |
358 | 294 |
359 void FreeBitstreamBuffers(struct vpx_fixed_buf *const inputs, const int n) { | 295 void FreeBitstreamBuffers(struct vpx_fixed_buf *const inputs, const int n) { |
360 ASSERT_TRUE(inputs != NULL); | 296 ASSERT_TRUE(inputs != NULL); |
361 ASSERT_GT(n, 0); | 297 ASSERT_GT(n, 0); |
362 | 298 |
363 for (int i = 0; i < n; ++i) { | 299 for (int i = 0; i < n; ++i) { |
364 free(inputs[i].buf); | 300 free(inputs[i].buf); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // First pass encode | 484 // First pass encode |
549 std::string stats_buf; | 485 std::string stats_buf; |
550 Pass1EncodeNFrames(10, 2, &stats_buf); | 486 Pass1EncodeNFrames(10, 2, &stats_buf); |
551 | 487 |
552 // Second pass encode | 488 // Second pass encode |
553 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 489 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
554 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1"); | 490 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1"); |
555 vpx_fixed_buf outputs[10]; | 491 vpx_fixed_buf outputs[10]; |
556 memset(&outputs[0], 0, sizeof(outputs)); | 492 memset(&outputs[0], 0, sizeof(outputs)); |
557 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); | 493 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); |
558 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 1, false); | 494 DropEnhancementLayers(&outputs[0], 10, 1); |
559 DecodeNFrames(&outputs[0], 10); | 495 DecodeNFrames(&outputs[0], 10); |
560 FreeBitstreamBuffers(&outputs[0], 10); | 496 FreeBitstreamBuffers(&outputs[0], 10); |
561 } | 497 } |
562 | 498 |
563 TEST_F(SvcTest, TwoPassEncode5SpatialLayersDecode54321Layers) { | 499 TEST_F(SvcTest, TwoPassEncode5SpatialLayersDecode54321Layers) { |
564 // First pass encode | 500 // First pass encode |
565 std::string stats_buf; | 501 std::string stats_buf; |
566 Pass1EncodeNFrames(10, 5, &stats_buf); | 502 Pass1EncodeNFrames(10, 5, &stats_buf); |
567 | 503 |
568 // Second pass encode | 504 // Second pass encode |
569 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 505 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
570 vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0"); | 506 vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0"); |
571 vpx_fixed_buf outputs[10]; | 507 vpx_fixed_buf outputs[10]; |
572 memset(&outputs[0], 0, sizeof(outputs)); | 508 memset(&outputs[0], 0, sizeof(outputs)); |
573 Pass2EncodeNFrames(&stats_buf, 10, 5, &outputs[0]); | 509 Pass2EncodeNFrames(&stats_buf, 10, 5, &outputs[0]); |
574 | 510 |
575 DecodeNFrames(&outputs[0], 10); | 511 DecodeNFrames(&outputs[0], 10); |
576 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 4, false); | 512 DropEnhancementLayers(&outputs[0], 10, 4); |
577 DecodeNFrames(&outputs[0], 10); | 513 DecodeNFrames(&outputs[0], 10); |
578 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 3, false); | 514 DropEnhancementLayers(&outputs[0], 10, 3); |
579 DecodeNFrames(&outputs[0], 10); | 515 DecodeNFrames(&outputs[0], 10); |
580 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 2, false); | 516 DropEnhancementLayers(&outputs[0], 10, 2); |
581 DecodeNFrames(&outputs[0], 10); | 517 DecodeNFrames(&outputs[0], 10); |
582 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 1, false); | 518 DropEnhancementLayers(&outputs[0], 10, 1); |
583 DecodeNFrames(&outputs[0], 10); | 519 DecodeNFrames(&outputs[0], 10); |
584 | 520 |
585 FreeBitstreamBuffers(&outputs[0], 10); | 521 FreeBitstreamBuffers(&outputs[0], 10); |
586 } | 522 } |
587 | 523 |
588 TEST_F(SvcTest, TwoPassEncode2SNRLayers) { | 524 TEST_F(SvcTest, TwoPassEncode2SNRLayers) { |
589 // First pass encode | 525 // First pass encode |
590 std::string stats_buf; | 526 std::string stats_buf; |
591 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1"); | 527 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1"); |
592 Pass1EncodeNFrames(20, 2, &stats_buf); | 528 Pass1EncodeNFrames(20, 2, &stats_buf); |
(...skipping 16 matching lines...) Expand all Loading... |
609 Pass1EncodeNFrames(20, 3, &stats_buf); | 545 Pass1EncodeNFrames(20, 3, &stats_buf); |
610 | 546 |
611 // Second pass encode | 547 // Second pass encode |
612 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 548 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
613 vpx_svc_set_options(&svc_, | 549 vpx_svc_set_options(&svc_, |
614 "auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1"); | 550 "auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1"); |
615 vpx_fixed_buf outputs[20]; | 551 vpx_fixed_buf outputs[20]; |
616 memset(&outputs[0], 0, sizeof(outputs)); | 552 memset(&outputs[0], 0, sizeof(outputs)); |
617 Pass2EncodeNFrames(&stats_buf, 20, 3, &outputs[0]); | 553 Pass2EncodeNFrames(&stats_buf, 20, 3, &outputs[0]); |
618 DecodeNFrames(&outputs[0], 20); | 554 DecodeNFrames(&outputs[0], 20); |
619 DropLayersAndMakeItVP9Comaptible(&outputs[0], 20, 2, false); | 555 DropEnhancementLayers(&outputs[0], 20, 2); |
620 DecodeNFrames(&outputs[0], 20); | 556 DecodeNFrames(&outputs[0], 20); |
621 DropLayersAndMakeItVP9Comaptible(&outputs[0], 20, 1, false); | 557 DropEnhancementLayers(&outputs[0], 20, 1); |
622 DecodeNFrames(&outputs[0], 20); | 558 DecodeNFrames(&outputs[0], 20); |
623 | 559 |
624 FreeBitstreamBuffers(&outputs[0], 20); | 560 FreeBitstreamBuffers(&outputs[0], 20); |
625 } | 561 } |
626 | 562 |
627 TEST_F(SvcTest, SetMultipleFrameContextsOption) { | 563 TEST_F(SvcTest, SetMultipleFrameContextsOption) { |
628 svc_.spatial_layers = 5; | 564 svc_.spatial_layers = 5; |
629 vpx_codec_err_t res = | 565 vpx_codec_err_t res = |
630 vpx_svc_set_options(&svc_, "multi-frame-contexts=1"); | 566 vpx_svc_set_options(&svc_, "multi-frame-contexts=1"); |
631 EXPECT_EQ(VPX_CODEC_OK, res); | 567 EXPECT_EQ(VPX_CODEC_OK, res); |
(...skipping 10 matching lines...) Expand all Loading... |
642 std::string stats_buf; | 578 std::string stats_buf; |
643 Pass1EncodeNFrames(10, 2, &stats_buf); | 579 Pass1EncodeNFrames(10, 2, &stats_buf); |
644 | 580 |
645 // Second pass encode | 581 // Second pass encode |
646 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 582 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
647 codec_enc_.g_error_resilient = 0; | 583 codec_enc_.g_error_resilient = 0; |
648 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1"); | 584 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1"); |
649 vpx_fixed_buf outputs[10]; | 585 vpx_fixed_buf outputs[10]; |
650 memset(&outputs[0], 0, sizeof(outputs)); | 586 memset(&outputs[0], 0, sizeof(outputs)); |
651 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); | 587 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); |
652 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 2, true); | |
653 DecodeNFrames(&outputs[0], 10); | 588 DecodeNFrames(&outputs[0], 10); |
654 FreeBitstreamBuffers(&outputs[0], 10); | 589 FreeBitstreamBuffers(&outputs[0], 10); |
655 } | 590 } |
656 | 591 |
657 TEST_F(SvcTest, | 592 TEST_F(SvcTest, |
658 TwoPassEncode2SpatialLayersWithMultipleFrameContextsDecodeBaselayer) { | 593 TwoPassEncode2SpatialLayersWithMultipleFrameContextsDecodeBaselayer) { |
659 // First pass encode | 594 // First pass encode |
660 std::string stats_buf; | 595 std::string stats_buf; |
661 Pass1EncodeNFrames(10, 2, &stats_buf); | 596 Pass1EncodeNFrames(10, 2, &stats_buf); |
662 | 597 |
663 // Second pass encode | 598 // Second pass encode |
664 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 599 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
665 codec_enc_.g_error_resilient = 0; | 600 codec_enc_.g_error_resilient = 0; |
666 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1"); | 601 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1"); |
667 vpx_fixed_buf outputs[10]; | 602 vpx_fixed_buf outputs[10]; |
668 memset(&outputs[0], 0, sizeof(outputs)); | 603 memset(&outputs[0], 0, sizeof(outputs)); |
669 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); | 604 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); |
670 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 1, true); | 605 DropEnhancementLayers(&outputs[0], 10, 1); |
671 DecodeNFrames(&outputs[0], 10); | 606 DecodeNFrames(&outputs[0], 10); |
672 FreeBitstreamBuffers(&outputs[0], 10); | 607 FreeBitstreamBuffers(&outputs[0], 10); |
673 } | 608 } |
674 | 609 |
675 TEST_F(SvcTest, TwoPassEncode2SNRLayersWithMultipleFrameContexts) { | 610 TEST_F(SvcTest, TwoPassEncode2SNRLayersWithMultipleFrameContexts) { |
676 // First pass encode | 611 // First pass encode |
677 std::string stats_buf; | 612 std::string stats_buf; |
678 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1"); | 613 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1"); |
679 Pass1EncodeNFrames(10, 2, &stats_buf); | 614 Pass1EncodeNFrames(10, 2, &stats_buf); |
680 | 615 |
681 // Second pass encode | 616 // Second pass encode |
682 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 617 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
683 codec_enc_.g_error_resilient = 0; | 618 codec_enc_.g_error_resilient = 0; |
684 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 scale-factors=1/1,1/1 " | 619 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 scale-factors=1/1,1/1 " |
685 "multi-frame-contexts=1"); | 620 "multi-frame-contexts=1"); |
686 vpx_fixed_buf outputs[10]; | 621 vpx_fixed_buf outputs[10]; |
687 memset(&outputs[0], 0, sizeof(outputs)); | 622 memset(&outputs[0], 0, sizeof(outputs)); |
688 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); | 623 Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]); |
689 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 2, true); | |
690 DecodeNFrames(&outputs[0], 10); | 624 DecodeNFrames(&outputs[0], 10); |
691 FreeBitstreamBuffers(&outputs[0], 10); | 625 FreeBitstreamBuffers(&outputs[0], 10); |
692 } | 626 } |
693 | 627 |
694 TEST_F(SvcTest, | 628 TEST_F(SvcTest, |
695 TwoPassEncode3SNRLayersWithMultipleFrameContextsDecode321Layer) { | 629 TwoPassEncode3SNRLayersWithMultipleFrameContextsDecode321Layer) { |
696 // First pass encode | 630 // First pass encode |
697 std::string stats_buf; | 631 std::string stats_buf; |
698 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1,1/1"); | 632 vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1,1/1"); |
699 Pass1EncodeNFrames(10, 3, &stats_buf); | 633 Pass1EncodeNFrames(10, 3, &stats_buf); |
700 | 634 |
701 // Second pass encode | 635 // Second pass encode |
702 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 636 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
703 codec_enc_.g_error_resilient = 0; | 637 codec_enc_.g_error_resilient = 0; |
704 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1 " | 638 vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1 " |
705 "multi-frame-contexts=1"); | 639 "multi-frame-contexts=1"); |
706 vpx_fixed_buf outputs[10]; | 640 vpx_fixed_buf outputs[10]; |
707 memset(&outputs[0], 0, sizeof(outputs)); | 641 memset(&outputs[0], 0, sizeof(outputs)); |
708 Pass2EncodeNFrames(&stats_buf, 10, 3, &outputs[0]); | 642 Pass2EncodeNFrames(&stats_buf, 10, 3, &outputs[0]); |
709 | 643 |
710 vpx_fixed_buf outputs_new[10]; | 644 DecodeNFrames(&outputs[0], 10); |
711 for (int i = 0; i < 10; ++i) { | 645 DropEnhancementLayers(&outputs[0], 10, 2); |
712 outputs_new[i].buf = malloc(outputs[i].sz + 16); | 646 DecodeNFrames(&outputs[0], 10); |
713 ASSERT_TRUE(outputs_new[i].buf != NULL); | 647 DropEnhancementLayers(&outputs[0], 10, 1); |
714 memcpy(outputs_new[i].buf, outputs[i].buf, outputs[i].sz); | 648 DecodeNFrames(&outputs[0], 10); |
715 outputs_new[i].sz = outputs[i].sz; | |
716 } | |
717 DropLayersAndMakeItVP9Comaptible(&outputs_new[0], 10, 3, true); | |
718 DecodeNFrames(&outputs_new[0], 10); | |
719 | |
720 for (int i = 0; i < 10; ++i) { | |
721 memcpy(outputs_new[i].buf, outputs[i].buf, outputs[i].sz); | |
722 outputs_new[i].sz = outputs[i].sz; | |
723 } | |
724 DropLayersAndMakeItVP9Comaptible(&outputs_new[0], 10, 2, true); | |
725 DecodeNFrames(&outputs_new[0], 10); | |
726 | |
727 for (int i = 0; i < 10; ++i) { | |
728 memcpy(outputs_new[i].buf, outputs[i].buf, outputs[i].sz); | |
729 outputs_new[i].sz = outputs[i].sz; | |
730 } | |
731 DropLayersAndMakeItVP9Comaptible(&outputs_new[0], 10, 1, true); | |
732 DecodeNFrames(&outputs_new[0], 10); | |
733 | 649 |
734 FreeBitstreamBuffers(&outputs[0], 10); | 650 FreeBitstreamBuffers(&outputs[0], 10); |
735 FreeBitstreamBuffers(&outputs_new[0], 10); | |
736 } | 651 } |
737 | 652 |
738 TEST_F(SvcTest, TwoPassEncode2TemporalLayers) { | 653 TEST_F(SvcTest, TwoPassEncode2TemporalLayers) { |
739 // First pass encode | 654 // First pass encode |
740 std::string stats_buf; | 655 std::string stats_buf; |
741 vpx_svc_set_options(&svc_, "scale-factors=1/1"); | 656 vpx_svc_set_options(&svc_, "scale-factors=1/1"); |
742 svc_.temporal_layers = 2; | 657 svc_.temporal_layers = 2; |
743 Pass1EncodeNFrames(10, 1, &stats_buf); | 658 Pass1EncodeNFrames(10, 1, &stats_buf); |
744 | 659 |
745 // Second pass encode | 660 // Second pass encode |
(...skipping 16 matching lines...) Expand all Loading... |
762 | 677 |
763 // Second pass encode | 678 // Second pass encode |
764 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 679 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
765 svc_.temporal_layers = 2; | 680 svc_.temporal_layers = 2; |
766 codec_enc_.g_error_resilient = 0; | 681 codec_enc_.g_error_resilient = 0; |
767 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 " | 682 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 " |
768 "multi-frame-contexts=1"); | 683 "multi-frame-contexts=1"); |
769 vpx_fixed_buf outputs[10]; | 684 vpx_fixed_buf outputs[10]; |
770 memset(&outputs[0], 0, sizeof(outputs)); | 685 memset(&outputs[0], 0, sizeof(outputs)); |
771 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]); | 686 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]); |
772 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 1, true); | |
773 DecodeNFrames(&outputs[0], 10); | 687 DecodeNFrames(&outputs[0], 10); |
774 FreeBitstreamBuffers(&outputs[0], 10); | 688 FreeBitstreamBuffers(&outputs[0], 10); |
775 } | 689 } |
776 | 690 |
777 TEST_F(SvcTest, TwoPassEncode2TemporalLayersDecodeBaseLayer) { | 691 TEST_F(SvcTest, TwoPassEncode2TemporalLayersDecodeBaseLayer) { |
778 // First pass encode | 692 // First pass encode |
779 std::string stats_buf; | 693 std::string stats_buf; |
780 vpx_svc_set_options(&svc_, "scale-factors=1/1"); | 694 vpx_svc_set_options(&svc_, "scale-factors=1/1"); |
781 svc_.temporal_layers = 2; | 695 svc_.temporal_layers = 2; |
782 Pass1EncodeNFrames(10, 1, &stats_buf); | 696 Pass1EncodeNFrames(10, 1, &stats_buf); |
(...skipping 24 matching lines...) Expand all Loading... |
807 | 721 |
808 // Second pass encode | 722 // Second pass encode |
809 codec_enc_.g_pass = VPX_RC_LAST_PASS; | 723 codec_enc_.g_pass = VPX_RC_LAST_PASS; |
810 svc_.temporal_layers = 2; | 724 svc_.temporal_layers = 2; |
811 codec_enc_.g_error_resilient = 0; | 725 codec_enc_.g_error_resilient = 0; |
812 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 " | 726 vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 " |
813 "multi-frame-contexts=1"); | 727 "multi-frame-contexts=1"); |
814 vpx_fixed_buf outputs[10]; | 728 vpx_fixed_buf outputs[10]; |
815 memset(&outputs[0], 0, sizeof(outputs)); | 729 memset(&outputs[0], 0, sizeof(outputs)); |
816 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]); | 730 Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]); |
817 DropLayersAndMakeItVP9Comaptible(&outputs[0], 10, 1, true); | |
818 | 731 |
819 vpx_fixed_buf base_layer[5]; | 732 vpx_fixed_buf base_layer[5]; |
820 for (int i = 0; i < 5; ++i) | 733 for (int i = 0; i < 5; ++i) |
821 base_layer[i] = outputs[i * 2]; | 734 base_layer[i] = outputs[i * 2]; |
822 | 735 |
823 DecodeNFrames(&base_layer[0], 5); | 736 DecodeNFrames(&base_layer[0], 5); |
824 FreeBitstreamBuffers(&outputs[0], 10); | 737 FreeBitstreamBuffers(&outputs[0], 10); |
825 } | 738 } |
826 | 739 |
827 } // namespace | 740 } // namespace |
OLD | NEW |