Skip to content

Instantly share code, notes, and snippets.

@yannick
Created March 14, 2010 21:16
Show Gist options
  • Save yannick/332245 to your computer and use it in GitHub Desktop.
Save yannick/332245 to your computer and use it in GitHub Desktop.
From 9326446b98e2bad9f36ab4bc6286ad89ef21cb67 Mon Sep 17 00:00:00 2001
From: Yannick Kechlin <[email protected]>
Date: Sun, 14 Mar 2010 22:13:11 +0100
Subject: [PATCH] sha nicyfied
---
libavformat/shaenc.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/libavformat/shaenc.c b/libavformat/shaenc.c
index b14d4b2..91f9a6e 100755
--- a/libavformat/shaenc.c
+++ b/libavformat/shaenc.c
@@ -56,14 +56,17 @@ static int sha_write_trailer(struct AVFormatContext *s)
char buf[64];
unsigned char avsha1[20];
- av_sha_final(avshactx, &avsha1);
+ unsigned char sha1out[40];
+
+ av_sha_final(avshactx, &avsha1);
- snprintf(buf, sizeof(buf), "\nSHA=");
- int i;
- for (i = 0; i < 20; i++) {
- snprintf(buf+5+(i*2), sizeof(buf), "%02x", avsha1[i]);
- }
-// snprintf(buf+46, sizeof(buf), "\n");
+
+ int i;
+ for (i = 0; i < 20; i++) {
+ snprintf(sha1out+(i*2), sizeof(buf), "%02x", avsha1[i]);
+ }
+ snprintf(buf, sizeof(buf), "%s\n", sha1out);
+
put_buffer(s->pb, buf, strlen(buf));
put_flush_packet(s->pb);
return 0;
--
1.7.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment