Skip to content

Commit 5787bc9

Browse files
authored
Merge pull request discord#126 from discord/wmcd/length
Set contentLength field in all ImageHeaders
2 parents b084235 + d8d3ecc commit 5787bc9

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

avcodec.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ func (d *avCodecDecoder) Duration() time.Duration {
6464

6565
func (d *avCodecDecoder) Header() (*ImageHeader, error) {
6666
return &ImageHeader{
67-
width: int(C.avcodec_decoder_get_width(d.decoder)),
68-
height: int(C.avcodec_decoder_get_height(d.decoder)),
69-
pixelType: PixelType(C.CV_8UC4),
70-
orientation: ImageOrientation(C.avcodec_decoder_get_orientation(d.decoder)),
71-
numFrames: 1,
67+
width: int(C.avcodec_decoder_get_width(d.decoder)),
68+
height: int(C.avcodec_decoder_get_height(d.decoder)),
69+
pixelType: PixelType(C.CV_8UC4),
70+
orientation: ImageOrientation(C.avcodec_decoder_get_orientation(d.decoder)),
71+
numFrames: 1,
72+
contentLength: len(d.buf),
7273
}, nil
7374
}
7475

giflib.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,23 @@ func newGifDecoder(buf []byte) (*gifDecoder, error) {
7272

7373
func (d *gifDecoder) Header() (*ImageHeader, error) {
7474
return &ImageHeader{
75-
width: int(C.giflib_decoder_get_width(d.decoder)),
76-
height: int(C.giflib_decoder_get_height(d.decoder)),
77-
pixelType: PixelType(C.CV_8UC4),
78-
orientation: OrientationTopLeft,
79-
numFrames: int(C.giflib_decoder_get_num_frames(d.decoder)),
75+
width: int(C.giflib_decoder_get_width(d.decoder)),
76+
height: int(C.giflib_decoder_get_height(d.decoder)),
77+
pixelType: PixelType(C.CV_8UC4),
78+
orientation: OrientationTopLeft,
79+
numFrames: int(C.giflib_decoder_get_num_frames(d.decoder)),
80+
contentLength: len(d.buf),
8081
}, nil
8182
}
8283

8384
func (d *gifDecoder) FrameHeader() (*ImageHeader, error) {
8485
return &ImageHeader{
85-
width: int(C.giflib_decoder_get_frame_width(d.decoder)),
86-
height: int(C.giflib_decoder_get_frame_height(d.decoder)),
87-
pixelType: PixelType(C.CV_8UC4),
88-
orientation: OrientationTopLeft,
89-
numFrames: 1,
86+
width: int(C.giflib_decoder_get_frame_width(d.decoder)),
87+
height: int(C.giflib_decoder_get_frame_height(d.decoder)),
88+
pixelType: PixelType(C.CV_8UC4),
89+
orientation: OrientationTopLeft,
90+
numFrames: 1,
91+
contentLength: len(d.buf),
9092
}, nil
9193
}
9294

0 commit comments

Comments
 (0)