Skip to content

Commit

Permalink
Merge pull request discord#126 from discord/wmcd/length
Browse files Browse the repository at this point in the history
Set contentLength field in all ImageHeaders
  • Loading branch information
walruscow authored Apr 17, 2023
2 parents b084235 + d8d3ecc commit 5787bc9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
11 changes: 6 additions & 5 deletions avcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ func (d *avCodecDecoder) Duration() time.Duration {

func (d *avCodecDecoder) Header() (*ImageHeader, error) {
return &ImageHeader{
width: int(C.avcodec_decoder_get_width(d.decoder)),
height: int(C.avcodec_decoder_get_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: ImageOrientation(C.avcodec_decoder_get_orientation(d.decoder)),
numFrames: 1,
width: int(C.avcodec_decoder_get_width(d.decoder)),
height: int(C.avcodec_decoder_get_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: ImageOrientation(C.avcodec_decoder_get_orientation(d.decoder)),
numFrames: 1,
contentLength: len(d.buf),
}, nil
}

Expand Down
22 changes: 12 additions & 10 deletions giflib.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,23 @@ func newGifDecoder(buf []byte) (*gifDecoder, error) {

func (d *gifDecoder) Header() (*ImageHeader, error) {
return &ImageHeader{
width: int(C.giflib_decoder_get_width(d.decoder)),
height: int(C.giflib_decoder_get_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: OrientationTopLeft,
numFrames: int(C.giflib_decoder_get_num_frames(d.decoder)),
width: int(C.giflib_decoder_get_width(d.decoder)),
height: int(C.giflib_decoder_get_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: OrientationTopLeft,
numFrames: int(C.giflib_decoder_get_num_frames(d.decoder)),
contentLength: len(d.buf),
}, nil
}

func (d *gifDecoder) FrameHeader() (*ImageHeader, error) {
return &ImageHeader{
width: int(C.giflib_decoder_get_frame_width(d.decoder)),
height: int(C.giflib_decoder_get_frame_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: OrientationTopLeft,
numFrames: 1,
width: int(C.giflib_decoder_get_frame_width(d.decoder)),
height: int(C.giflib_decoder_get_frame_height(d.decoder)),
pixelType: PixelType(C.CV_8UC4),
orientation: OrientationTopLeft,
numFrames: 1,
contentLength: len(d.buf),
}, nil
}

Expand Down

0 comments on commit 5787bc9

Please sign in to comment.