John Koleszarexamples: fix memory leak4d3c3be14 years agoHistory
74 lines · 2.7 KB · Text
RawDownload
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES#define VPX_CODEC_DISABLE_COMPAT 1#include "vpx/vpx_encoder.h"#include "vpx/vp8cx.h"#define interface (vpx_codec_vp8_cx())~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INCLUDES  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODECstatic void die_codec(vpx_codec_ctx_t *ctx, const char *s) {    const char *detail = vpx_codec_error_detail(ctx);     printf("%s: %s\n", s, vpx_codec_error(ctx));    if(detail)        printf("    %s\n",detail);    exit(EXIT_FAILURE);}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DIE_CODEC  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGEif(argc!=5)    die("Usage: %s <width> <height> <infile> <outfile>\n", argv[0]);~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ USAGE  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_DEF_CFG/* Populate encoder configuration */res = vpx_codec_enc_config_default(interface, &cfg, 0);if(res) {    printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));    return EXIT_FAILURE;}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_DEF_CFG  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG/* Update the default configuration with our settings */cfg.rc_target_bitrate = width * height * cfg.rc_target_bitrate                        / cfg.g_w / cfg.g_h;cfg.g_w = width;cfg.g_h = height;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_SET_CFG  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INIT/* Initialize codec */if(vpx_codec_enc_init(&codec, interface, &cfg, 0))    die_codec(&codec, "Failed to initialize encoder");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENC_INIT  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENCODE_FRAMEframe_avail = read_frame(infile, &raw);if(vpx_codec_encode(&codec, frame_avail? &raw : NULL, frame_cnt,                    1, flags, VPX_DL_REALTIME))    die_codec(&codec, "Failed to encode frame");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ENCODE_FRAME  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_FRAMEcase VPX_CODEC_CX_FRAME_PKT:    write_ivf_frame_header(outfile, pkt);    (void) fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz,                  outfile);    break;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_FRAME  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROYvpx_img_free(&raw);if(vpx_codec_destroy(&codec))    die_codec(&codec, "Failed to destroy codec");~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DESTROY

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t