Mercurial > libavcodec.hg
comparison flacenc.c @ 4149:3118e8afb8a5 libavcodec
Fix ASF format parser's broken UTF-16 string handling
1. Add a PUT_UTF8 macro to common.h; code borrowed from libavcodec/flacenc.c.
2. Make use of the macro in flacenc.c
Patch by Zuxy Meng % zuxy P meng A gmail P com %
Original thread:
Date: Nov 5, 2006 9:56 AM
Subject: [Ffmpeg-devel] PUT_UTF8 & asf format enhancement
author | gpoirier |
---|---|
date | Mon, 06 Nov 2006 10:32:48 +0000 |
parents | 34fdffe98bd0 |
children | a96d905dcbaa |
comparison
equal
deleted
inserted
replaced
4148:228252c41929 | 4149:3118e8afb8a5 |
---|---|
1120 put_bits(pb, bits, val & ((1<<bits)-1)); | 1120 put_bits(pb, bits, val & ((1<<bits)-1)); |
1121 } | 1121 } |
1122 | 1122 |
1123 static void write_utf8(PutBitContext *pb, uint32_t val) | 1123 static void write_utf8(PutBitContext *pb, uint32_t val) |
1124 { | 1124 { |
1125 int bytes, shift; | 1125 uint8_t tmp; |
1126 | 1126 PUT_UTF8(val, tmp, put_bits(pb, 8, tmp);) |
1127 if(val < 0x80){ | |
1128 put_bits(pb, 8, val); | |
1129 return; | |
1130 } | |
1131 | |
1132 bytes= (av_log2(val)+4) / 5; | |
1133 shift = (bytes - 1) * 6; | |
1134 put_bits(pb, 8, (256 - (256>>bytes)) | (val >> shift)); | |
1135 while(shift >= 6){ | |
1136 shift -= 6; | |
1137 put_bits(pb, 8, 0x80 | ((val >> shift) & 0x3F)); | |
1138 } | |
1139 } | 1127 } |
1140 | 1128 |
1141 static void output_frame_header(FlacEncodeContext *s) | 1129 static void output_frame_header(FlacEncodeContext *s) |
1142 { | 1130 { |
1143 FlacFrame *frame; | 1131 FlacFrame *frame; |