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

Side by Side Diff: source/libvpx/vp8/vp8_cx_iface.c

Issue 554673004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp8/vp8_common.mk ('k') | source/libvpx/vp8/vp8_dx_iface.c » ('j') | 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 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 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
11 11
12 #include "./vpx_config.h" 12 #include "./vpx_config.h"
13 #include "vp8_rtcd.h" 13 #include "vp8_rtcd.h"
14 #include "vpx/vpx_codec.h" 14 #include "vpx/vpx_codec.h"
15 #include "vpx/internal/vpx_codec_internal.h" 15 #include "vpx/internal/vpx_codec_internal.h"
16 #include "vpx_version.h" 16 #include "vpx_version.h"
17 #include "vpx_mem/vpx_mem.h"
17 #include "vp8/encoder/onyx_int.h" 18 #include "vp8/encoder/onyx_int.h"
18 #include "vpx/vp8cx.h" 19 #include "vpx/vp8cx.h"
19 #include "vp8/encoder/firstpass.h" 20 #include "vp8/encoder/firstpass.h"
20 #include "vp8/common/onyx.h" 21 #include "vp8/common/onyx.h"
21 #include <stdlib.h> 22 #include <stdlib.h>
22 #include <string.h> 23 #include <string.h>
23 24
24 struct vp8_extracfg 25 struct vp8_extracfg
25 { 26 {
26 struct vpx_codec_pkt_list *pkt_list; 27 struct vpx_codec_pkt_list *pkt_list;
27 int cpu_used; /** available cpu p ercentage in 1/16*/ 28 int cpu_used; /** available cpu p ercentage in 1/16*/
28 unsigned int enable_auto_alt_ref; /** if encoder de cides to uses alternate reference frame */ 29 unsigned int enable_auto_alt_ref; /** if encoder de cides to uses alternate reference frame */
29 unsigned int noise_sensitivity; 30 unsigned int noise_sensitivity;
30 unsigned int Sharpness; 31 unsigned int Sharpness;
31 unsigned int static_thresh; 32 unsigned int static_thresh;
32 unsigned int token_partitions; 33 unsigned int token_partitions;
33 unsigned int arnr_max_frames; /* alt_ref Noise Reduction M ax Frame Count */ 34 unsigned int arnr_max_frames; /* alt_ref Noise Reduction M ax Frame Count */
34 unsigned int arnr_strength; /* alt_ref Noise Reduction Str ength */ 35 unsigned int arnr_strength; /* alt_ref Noise Reduction Str ength */
35 unsigned int arnr_type; /* alt_ref filter type */ 36 unsigned int arnr_type; /* alt_ref filter type */
36 vp8e_tuning tuning; 37 vp8e_tuning tuning;
37 unsigned int cq_level; /* constrained quality level * / 38 unsigned int cq_level; /* constrained quality level * /
38 unsigned int rc_max_intra_bitrate_pct; 39 unsigned int rc_max_intra_bitrate_pct;
39 40
40 }; 41 };
41 42
42 struct extraconfig_map 43 static struct vp8_extracfg default_extracfg = {
43 { 44 NULL,
44 int usage;
45 struct vp8_extracfg cfg;
46 };
47
48 static const struct extraconfig_map extracfg_map[] =
49 {
50 {
51 0,
52 {
53 NULL,
54 #if !(CONFIG_REALTIME_ONLY) 45 #if !(CONFIG_REALTIME_ONLY)
55 0, /* cpu_used */ 46 0, /* cpu_used */
56 #else 47 #else
57 4, /* cpu_used */ 48 4, /* cpu_used */
58 #endif 49 #endif
59 0, /* enable_auto_alt_ref */ 50 0, /* enable_auto_alt_ref */
60 0, /* noise_sensitivity */ 51 0, /* noise_sensitivity */
61 0, /* Sharpness */ 52 0, /* Sharpness */
62 0, /* static_thresh */ 53 0, /* static_thresh */
63 #if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) 54 #if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING)
64 VP8_EIGHT_TOKENPARTITION, 55 VP8_EIGHT_TOKENPARTITION,
65 #else 56 #else
66 VP8_ONE_TOKENPARTITION, /* token_partitions */ 57 VP8_ONE_TOKENPARTITION, /* token_partitions */
67 #endif 58 #endif
68 0, /* arnr_max_frames */ 59 0, /* arnr_max_frames */
69 3, /* arnr_strength */ 60 3, /* arnr_strength */
70 3, /* arnr_type*/ 61 3, /* arnr_type*/
71 0, /* tuning*/ 62 0, /* tuning*/
72 10, /* cq_level */ 63 10, /* cq_level */
73 0, /* rc_max_intra_bitrate_pct */ 64 0, /* rc_max_intra_bitrate_pct */
74 }
75 }
76 }; 65 };
77 66
78 struct vpx_codec_alg_priv 67 struct vpx_codec_alg_priv
79 { 68 {
80 vpx_codec_priv_t base; 69 vpx_codec_priv_t base;
81 vpx_codec_enc_cfg_t cfg; 70 vpx_codec_enc_cfg_t cfg;
82 struct vp8_extracfg vp8_cfg; 71 struct vp8_extracfg vp8_cfg;
83 VP8_CONFIG oxcf; 72 VP8_CONFIG oxcf;
84 struct VP8_COMP *cpi; 73 struct VP8_COMP *cpi;
85 unsigned char *cx_data; 74 unsigned char *cx_data;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 res = VPX_CODEC_OK; 613 res = VPX_CODEC_OK;
625 } 614 }
626 #endif 615 #endif
627 return res; 616 return res;
628 } 617 }
629 618
630 static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, 619 static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
631 vpx_codec_priv_enc_mr_cfg_t *mr_cfg) 620 vpx_codec_priv_enc_mr_cfg_t *mr_cfg)
632 { 621 {
633 vpx_codec_err_t res = VPX_CODEC_OK; 622 vpx_codec_err_t res = VPX_CODEC_OK;
634 struct vpx_codec_alg_priv *priv;
635 vpx_codec_enc_cfg_t *cfg;
636 unsigned int i;
637 623
638 struct VP8_COMP *optr;
639 624
640 vp8_rtcd(); 625 vp8_rtcd();
641 626
642 if (!ctx->priv) 627 if (!ctx->priv)
643 { 628 {
644 priv = calloc(1, sizeof(struct vpx_codec_alg_priv)); 629 struct vpx_codec_alg_priv *priv =
630 (struct vpx_codec_alg_priv *)vpx_calloc(1, sizeof(*priv));
645 631
646 if (!priv) 632 if (!priv)
647 { 633 {
648 return VPX_CODEC_MEM_ERROR; 634 return VPX_CODEC_MEM_ERROR;
649 } 635 }
650 636
651 ctx->priv = &priv->base; 637 ctx->priv = (vpx_codec_priv_t *)priv;
652 ctx->priv->sz = sizeof(*ctx->priv);
653 ctx->priv->alg_priv = priv;
654 ctx->priv->init_flags = ctx->init_flags; 638 ctx->priv->init_flags = ctx->init_flags;
655 639
656 if (ctx->config.enc) 640 if (ctx->config.enc)
657 { 641 {
658 /* Update the reference to the config structure to an 642 /* Update the reference to the config structure to an
659 * internal copy. 643 * internal copy.
660 */ 644 */
661 ctx->priv->alg_priv->cfg = *ctx->config.enc; 645 priv->cfg = *ctx->config.enc;
662 ctx->config.enc = &ctx->priv->alg_priv->cfg; 646 ctx->config.enc = &priv->cfg;
663 } 647 }
664 648
665 cfg = &ctx->priv->alg_priv->cfg; 649 priv->vp8_cfg = default_extracfg;
666
667 /* Select the extra vp8 configuration table based on the current
668 * usage value. If the current usage value isn't found, use the
669 * values for usage case 0.
670 */
671 for (i = 0;
672 extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage;
673 i++);
674
675 priv->vp8_cfg = extracfg_map[i].cfg;
676 priv->vp8_cfg.pkt_list = &priv->pkt_list.head; 650 priv->vp8_cfg.pkt_list = &priv->pkt_list.head;
677 651
678 priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2; 652 priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2;
679 653
680 if (priv->cx_data_sz < 32768) priv->cx_data_sz = 32768; 654 if (priv->cx_data_sz < 32768) priv->cx_data_sz = 32768;
681 655
682 priv->cx_data = malloc(priv->cx_data_sz); 656 priv->cx_data = malloc(priv->cx_data_sz);
683 657
684 if (!priv->cx_data) 658 if (!priv->cx_data)
685 { 659 {
686 return VPX_CODEC_MEM_ERROR; 660 return VPX_CODEC_MEM_ERROR;
687 } 661 }
688 662
689 if(mr_cfg) 663 if(mr_cfg)
690 ctx->priv->enc.total_encoders = mr_cfg->mr_total_resolutions; 664 ctx->priv->enc.total_encoders = mr_cfg->mr_total_resolutions;
691 else 665 else
692 ctx->priv->enc.total_encoders = 1; 666 ctx->priv->enc.total_encoders = 1;
693 667
694 res = validate_config(priv, &priv->cfg, &priv->vp8_cfg, 0); 668 res = validate_config(priv, &priv->cfg, &priv->vp8_cfg, 0);
695 669
696 if (!res) 670 if (!res)
697 { 671 {
698 set_vp8e_config(&ctx->priv->alg_priv->oxcf, 672 set_vp8e_config(&priv->oxcf, priv->cfg, priv->vp8_cfg, mr_cfg);
699 ctx->priv->alg_priv->cfg, 673 priv->cpi = vp8_create_compressor(&priv->oxcf);
700 ctx->priv->alg_priv->vp8_cfg, 674 if (!priv->cpi)
701 mr_cfg);
702
703 optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf);
704
705 if (!optr)
706 res = VPX_CODEC_MEM_ERROR; 675 res = VPX_CODEC_MEM_ERROR;
707 else
708 ctx->priv->alg_priv->cpi = optr;
709 } 676 }
710 } 677 }
711 678
712 return res; 679 return res;
713 } 680 }
714 681
715 static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) 682 static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx)
716 { 683 {
717 #if CONFIG_MULTI_RES_ENCODING 684 #if CONFIG_MULTI_RES_ENCODING
718 /* Free multi-encoder shared memory */ 685 /* Free multi-encoder shared memory */
719 if (ctx->oxcf.mr_total_resolutions > 0 && (ctx->oxcf.mr_encoder_id == ctx->o xcf.mr_total_resolutions-1)) 686 if (ctx->oxcf.mr_total_resolutions > 0 && (ctx->oxcf.mr_encoder_id == ctx->o xcf.mr_total_resolutions-1))
720 { 687 {
721 LOWER_RES_FRAME_INFO *shared_mem_loc = (LOWER_RES_FRAME_INFO *)ctx->oxcf .mr_low_res_mode_info; 688 LOWER_RES_FRAME_INFO *shared_mem_loc = (LOWER_RES_FRAME_INFO *)ctx->oxcf .mr_low_res_mode_info;
722 free(shared_mem_loc->mb_info); 689 free(shared_mem_loc->mb_info);
723 free(ctx->oxcf.mr_low_res_mode_info); 690 free(ctx->oxcf.mr_low_res_mode_info);
724 } 691 }
725 #endif 692 #endif
726 693
727 free(ctx->cx_data); 694 free(ctx->cx_data);
728 vp8_remove_compressor(&ctx->cpi); 695 vp8_remove_compressor(&ctx->cpi);
729 free(ctx); 696 vpx_free(ctx);
730 return VPX_CODEC_OK; 697 return VPX_CODEC_OK;
731 } 698 }
732 699
733 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, 700 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
734 YV12_BUFFER_CONFIG *yv12) 701 YV12_BUFFER_CONFIG *yv12)
735 { 702 {
736 const int y_w = img->d_w; 703 const int y_w = img->d_w;
737 const int y_h = img->d_h; 704 const int y_h = img->d_h;
738 const int uv_w = (img->d_w + 1) / 2; 705 const int uv_w = (img->d_w + 1) / 2;
739 const int uv_h = (img->d_h + 1) / 2; 706 const int uv_h = (img->d_h + 1) / 2;
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 { 1238 {
1272 { 1239 {
1273 0, 1240 0,
1274 { 1241 {
1275 0, /* g_usage */ 1242 0, /* g_usage */
1276 0, /* g_threads */ 1243 0, /* g_threads */
1277 0, /* g_profile */ 1244 0, /* g_profile */
1278 1245
1279 320, /* g_width */ 1246 320, /* g_width */
1280 240, /* g_height */ 1247 240, /* g_height */
1248 VPX_BITS_8, /* g_bit_depth */
1249 8, /* g_input_bit_depth */
1250
1281 {1, 30}, /* g_timebase */ 1251 {1, 30}, /* g_timebase */
1282 1252
1283 0, /* g_error_resilient */ 1253 0, /* g_error_resilient */
1284 1254
1285 VPX_RC_ONE_PASS, /* g_pass */ 1255 VPX_RC_ONE_PASS, /* g_pass */
1286 1256
1287 0, /* g_lag_in_frames */ 1257 0, /* g_lag_in_frames */
1288 1258
1289 0, /* rc_dropframe_thresh */ 1259 0, /* rc_dropframe_thresh */
1290 0, /* rc_resize_allowed */ 1260 0, /* rc_resize_allowed */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 { 1309 {
1340 "WebM Project VP8 Encoder" VERSION_STRING, 1310 "WebM Project VP8 Encoder" VERSION_STRING,
1341 VPX_CODEC_INTERNAL_ABI_VERSION, 1311 VPX_CODEC_INTERNAL_ABI_VERSION,
1342 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR | 1312 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR |
1343 VPX_CODEC_CAP_OUTPUT_PARTITION, 1313 VPX_CODEC_CAP_OUTPUT_PARTITION,
1344 /* vpx_codec_caps_t caps; */ 1314 /* vpx_codec_caps_t caps; */
1345 vp8e_init, /* vpx_codec_init_fn_t init; */ 1315 vp8e_init, /* vpx_codec_init_fn_t init; */
1346 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ 1316 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
1347 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ 1317 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
1348 { 1318 {
1349 NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */ 1319 NULL, /* vpx_codec_peek_si_fn_t peek_si; */
1350 NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */ 1320 NULL, /* vpx_codec_get_si_fn_t get_si; */
1351 NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */ 1321 NULL, /* vpx_codec_decode_fn_t decode; */
1352 NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ 1322 NULL, /* vpx_codec_frame_get_fn_t frame_get; */
1353 }, 1323 },
1354 { 1324 {
1355 1, /* 1 cfg map */ 1325 1, /* 1 cfg map */
1356 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ 1326 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
1357 vp8e_encode, /* vpx_codec_encode_fn_t encode; */ 1327 vp8e_encode, /* vpx_codec_encode_fn_t encode; */
1358 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ 1328 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
1359 vp8e_set_config, 1329 vp8e_set_config,
1360 NOT_IMPLEMENTED, 1330 NULL,
1361 vp8e_get_preview, 1331 vp8e_get_preview,
1362 vp8e_mr_alloc_mem, 1332 vp8e_mr_alloc_mem,
1363 } /* encoder functions */ 1333 } /* encoder functions */
1364 }; 1334 };
OLDNEW
« no previous file with comments | « source/libvpx/vp8/vp8_common.mk ('k') | source/libvpx/vp8/vp8_dx_iface.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698