mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-10 00:30:14 +00:00
avformat/md5proto: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
fbbe7729f0
commit
d203f6b4b3
@ -25,6 +25,7 @@
|
|||||||
#include "libavutil/error.h"
|
#include "libavutil/error.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
#include "avio.h"
|
#include "avio.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
|
|
||||||
struct MD5Context {
|
struct MD5Context {
|
||||||
@ -57,14 +58,13 @@ static int md5_close(URLContext *h)
|
|||||||
{
|
{
|
||||||
struct MD5Context *c = h->priv_data;
|
struct MD5Context *c = h->priv_data;
|
||||||
const char *filename = h->filename;
|
const char *filename = h->filename;
|
||||||
uint8_t md5[16], buf[64];
|
uint8_t md5[16], buf[2 * sizeof(md5) + 1];
|
||||||
URLContext *out;
|
URLContext *out;
|
||||||
int i, err = 0;
|
int err = 0;
|
||||||
|
|
||||||
av_md5_final(c->md5, md5);
|
av_md5_final(c->md5, md5);
|
||||||
for (i = 0; i < sizeof(md5); i++)
|
ff_data_to_hex(buf, md5, sizeof(md5), 1);
|
||||||
snprintf(buf + i*2, 3, "%02x", md5[i]);
|
buf[2 * sizeof(md5)] = '\n';
|
||||||
buf[i*2] = '\n';
|
|
||||||
|
|
||||||
av_strstart(filename, "md5:", &filename);
|
av_strstart(filename, "md5:", &filename);
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ static int md5_close(URLContext *h)
|
|||||||
h->protocol_whitelist, h->protocol_blacklist, h);
|
h->protocol_whitelist, h->protocol_blacklist, h);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
err = ffurl_write(out, buf, i*2+1);
|
err = ffurl_write(out, buf, sizeof(buf));
|
||||||
ffurl_close(out);
|
ffurl_close(out);
|
||||||
} else {
|
} else {
|
||||||
if (fwrite(buf, 1, i*2+1, stdout) < i*2+1)
|
if (fwrite(buf, 1, sizeof(buf), stdout) < sizeof(buf))
|
||||||
err = AVERROR(errno);
|
err = AVERROR(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user