Lines Matching refs:ctx
59 void *ctx;
92 const char *av_hash_get_name(const AVHashContext *ctx)
94 return hashdesc[ctx->type].name;
97 int av_hash_get_size(const AVHashContext *ctx)
99 return hashdesc[ctx->type].size;
102 int av_hash_alloc(AVHashContext **ctx, const char *name)
106 *ctx = NULL;
115 case MD5: res->ctx = av_md5_alloc(); break;
116 case MURMUR3: res->ctx = av_murmur3_alloc(); break;
120 case RIPEMD320: res->ctx = av_ripemd_alloc(); break;
123 case SHA256: res->ctx = av_sha_alloc(); break;
127 case SHA512: res->ctx = av_sha512_alloc(); break;
131 if (i != ADLER32 && i != CRC32 && !res->ctx) {
135 *ctx = res;
139 void av_hash_init(AVHashContext *ctx)
141 switch (ctx->type) {
142 case MD5: av_md5_init(ctx->ctx); break;
143 case MURMUR3: av_murmur3_init(ctx->ctx); break;
144 case RIPEMD128: av_ripemd_init(ctx->ctx, 128); break;
145 case RIPEMD160: av_ripemd_init(ctx->ctx, 160); break;
146 case RIPEMD256: av_ripemd_init(ctx->ctx, 256); break;
147 case RIPEMD320: av_ripemd_init(ctx->ctx, 320); break;
148 case SHA160: av_sha_init(ctx->ctx, 160); break;
149 case SHA224: av_sha_init(ctx->ctx, 224); break;
150 case SHA256: av_sha_init(ctx->ctx, 256); break;
151 case SHA512_224: av_sha512_init(ctx->ctx, 224); break;
152 case SHA512_256: av_sha512_init(ctx->ctx, 256); break;
153 case SHA384: av_sha512_init(ctx->ctx, 384); break;
154 case SHA512: av_sha512_init(ctx->ctx, 512); break;
155 case CRC32: ctx->crc = UINT32_MAX; break;
156 case ADLER32: ctx->crc = 1; break;
160 void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
162 switch (ctx->type) {
163 case MD5: av_md5_update(ctx->ctx, src, len); break;
164 case MURMUR3: av_murmur3_update(ctx->ctx, src, len); break;
168 case RIPEMD320: av_ripemd_update(ctx->ctx, src, len); break;
171 case SHA256: av_sha_update(ctx->ctx, src, len); break;
175 case SHA512: av_sha512_update(ctx->ctx, src, len); break;
176 case CRC32: ctx->crc = av_crc(ctx->crctab, ctx->crc, src, len); break;
177 case ADLER32: ctx->crc = av_adler32_update(ctx->crc, src, len); break;
181 void av_hash_final(AVHashContext *ctx, uint8_t *dst)
183 switch (ctx->type) {
184 case MD5: av_md5_final(ctx->ctx, dst); break;
185 case MURMUR3: av_murmur3_final(ctx->ctx, dst); break;
189 case RIPEMD320: av_ripemd_final(ctx->ctx, dst); break;
192 case SHA256: av_sha_final(ctx->ctx, dst); break;
196 case SHA512: av_sha512_final(ctx->ctx, dst); break;
197 case CRC32: AV_WB32(dst, ctx->crc ^ UINT32_MAX); break;
198 case ADLER32: AV_WB32(dst, ctx->crc); break;
202 void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size)
205 unsigned rsize = av_hash_get_size(ctx);
207 av_hash_final(ctx, buf);
213 void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
216 unsigned rsize = av_hash_get_size(ctx), i;
218 av_hash_final(ctx, buf);
223 void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size)
226 unsigned rsize = av_hash_get_size(ctx), osize;
228 av_hash_final(ctx, buf);
236 void av_hash_freep(AVHashContext **ctx)
238 if (*ctx)
239 av_freep(&(*ctx)->ctx);
240 av_freep(ctx);