void av_md5_final(AVMD5 *ctx, uint8_t *dst){ int i; uint64_t finalcount= le2me_64(ctx->len<<3); av_md5_update(ctx, "\200", 1); while((ctx->len & 63)<56) av_md5_update(ctx, "", 1); av_md5_update(ctx, &finalcount, 8); for(i=0; i<4; i++) ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]); }
static uint32_t draw_image(mp_image_t *mpi) { unsigned char md5sum[16]; uint32_t w = mpi->w; uint32_t h = mpi->h; uint8_t *rgbimage = mpi->planes[0]; uint8_t *planeY = mpi->planes[0]; uint8_t *planeU = mpi->planes[1]; uint8_t *planeV = mpi->planes[2]; uint32_t strideY = mpi->stride[0]; uint32_t strideU = mpi->stride[1]; uint32_t strideV = mpi->stride[2]; uint8_t md5_context_memory[av_md5_size]; struct AVMD5 *md5_context = (struct AVMD5*) md5_context_memory; unsigned int i; if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Planar */ if (mpi->flags & MP_IMGFLAG_YUV) { /* Planar YUV */ av_md5_init(md5_context); for (i=0; i<h; i++) { av_md5_update(md5_context, planeY + i * strideY, w); } w = w / 2; h = h / 2; for (i=0; i<h; i++) { av_md5_update(md5_context, planeU + i * strideU, w); } for (i=0; i<h; i++) { av_md5_update(md5_context, planeV + i * strideV, w); } av_md5_final(md5_context, md5sum); md5sum_output_sum(md5sum); return VO_TRUE; } else { /* Planar RGB */ return VO_FALSE; } } else { /* Packed */ if (mpi->flags & MP_IMGFLAG_YUV) { /* Packed YUV */ return VO_FALSE; } else { /* Packed RGB */ av_md5_sum(md5sum, rgbimage, mpi->w * (mpi->bpp >> 3) * mpi->h); md5sum_output_sum(md5sum); return VO_TRUE; } } return VO_FALSE; }
void av_md5_final(AVMD5 *ctx, uint8_t *dst) { int i; uint64_t finalcount = av_le2ne64(ctx->len << 3); av_md5_update(ctx, "\200", 1); while ((ctx->len & 63) != 56) av_md5_update(ctx, "", 1); av_md5_update(ctx, (uint8_t *)&finalcount, 8); for (i = 0; i < 4; i++) AV_WL32(dst + 4*i, ctx->ABCD[3 - i]); }
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ AVMD5 ctx[1]; av_md5_init(ctx); av_md5_update(ctx, src, len); av_md5_final(ctx, dst); }
static int io_write(void *opaque, uint8_t *buf, int size) { out_size += size; av_md5_update(md5, buf, size); if (out) fwrite(buf, 1, size, out); return size; }
void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len) #endif { AVMD5 ctx; av_md5_init(&ctx); av_md5_update(&ctx, src, len); av_md5_final(&ctx, dst); }
static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) { struct MD5Context *c = s->priv_data; char buf[256]; av_md5_init(c->md5); av_md5_update(c->md5, pkt->data, pkt->size); snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ", pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size); md5_finish(s, buf); return 0; }
static void update_md5_strings(struct AVMD5 *md5ctx, ...) { va_list vl; va_start(vl, md5ctx); while (1) { const char* str = va_arg(vl, const char*); if (!str) break; av_md5_update(md5ctx, str, strlen(str)); } va_end(vl); }
AlgorithmStatus AudioLoader::process() { if (!parameter("filename").isConfigured()) { throw EssentiaException("AudioLoader: Trying to call process() on an AudioLoader algo which hasn't been correctly configured."); } // read frames until we get a good one do { int result = av_read_frame(_demuxCtx, &_packet); //E_DEBUG(EAlgorithm, "AudioLoader: called av_read_frame(), got result = " << result); if (result != 0) { // 0 = OK, < 0 = error or EOF if (result != AVERROR_EOF) { char errstring[1204]; av_strerror(result, errstring, sizeof(errstring)); ostringstream msg; msg << "AudioLoader: Error reading frame: " << errstring; E_WARNING(msg.str()); } // TODO: should try reading again on EAGAIN error? // https://github.com/FFmpeg/FFmpeg/blob/master/ffmpeg.c shouldStop(true); flushPacket(); closeAudioFile(); if (_computeMD5) { av_md5_final(_md5Encoded, _checksum); _md5.push(uint8_t_to_hex(_checksum, 16)); } else { string md5 = ""; _md5.push(md5); } return FINISHED; } } while (_packet.stream_index != _streamIdx); // compute md5 first if (_computeMD5) { av_md5_update(_md5Encoded, _packet.data, _packet.size); } // decode frames in packet while(_packet.size > 0) { if (!decodePacket()) break; copyFFmpegOutput(); } // neds to be freed !! av_free_packet(&_packet); return OK; }
static int framemd5_write_packet(struct AVFormatContext *s, AVPacket *pkt) { char buf[256]; if (PRIVSIZE < av_md5_size) { av_log(s, AV_LOG_ERROR, "Insuffient size for md5 context\n"); return -1; } av_md5_init(s->priv_data); av_md5_update(s->priv_data, pkt->data, pkt->size); snprintf(buf, sizeof(buf) - 64, "%d, %10"PRId64", %10"PRId64", %8d, %8d, ", pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size); md5_finish(s, buf); return 0; }
static int md5_write(URLContext *h, const unsigned char *buf, int size) { struct MD5Context *c = h->priv_data; av_md5_update(c->md5, buf, size); return size; }
static int write_packet(struct AVFormatContext *s, AVPacket *pkt) { av_md5_update(s->priv_data, pkt->data, pkt->size); return 0; }
static int md5_write(URLContext *h, const unsigned char *buf, int size) { av_md5_update(h->priv_data, buf, size); return size; }
static int write_packet(struct AVFormatContext *s, AVPacket *pkt) { struct MD5Context *c = s->priv_data; av_md5_update(c->md5, pkt->data, pkt->size); return 0; }