Alex Beregszaszi wrote: > Hi, > >> +#define read16(bits) bswap_16(get_bits(bits, 16)) >> +#define read32(bits) bswap_32(get_bits_long(bits, 32)) > ... >> +#define write16(bits, val) put_bits(bits, 16, bswap_16(val)) >> +#define write32(bits, val) put_bits(bits, 32, bswap_32(val)) > > What about using bytestream.h or intreadwrite.h instead this? I dont see > its putting/reading non-8bit aligned data: Michael stated I could use whatever I wanted for the header. So I decided to use the same as Mans did for the decoder. It is conceivable to change *both* encoder and decoder to one of the byte-oriented APIs, but as Mans is the official maintainer, its his call. > >> + init_put_bits(&bits, buf, buf_size); >> + >> + // STRUCTURE.field refer to the MSVC documentation for BITMAPFILEHEADER >> + // and related pages. >> + put_bits(&bits, 8, 'B'); // BITMAPFILEHEADER.bfType >> + put_bits(&bits, 8, 'M'); // do. >> + write32(&bits, n_bytes); // BITMAPFILEHEADER.bfSize >> + write16(&bits, 0); // BITMAPFILEHEADER.bfReserved1 >> + write16(&bits, 0); // BITMAPFILEHEADER.bfReserved2 >> + hsize = 14 /* BITMAPFILEHEADER */ + 40; >> + write32(&bits, hsize); // BITMAPFILEHEADER.bfOffBits >> + write32(&bits, 40); // BITMAPINFOHEADER.biSize >> + write32(&bits, avctx->width); // BITMAPINFOHEADER.biWidth >> + write32(&bits, avctx->height); // BITMAPINFOHEADER.biHeight >> + write16(&bits, 1); // BITMAPINFOHEADER.biPlanes >> + write16(&bits, 24); // BITMAPINFOHEADER.biBitCount >> + write32(&bits, BMP_RGB); // BITMAPINFOHEADER.biCompression >> + write32(&bits, n_bytes_image); // BITMAPINFOHEADER.biSizeImage >> + write32(&bits, 0); // BITMAPINFOHEADER.biXPelsPerMeter >> + write32(&bits, 0); // BITMAPINFOHEADER.biYPelsPerMeter >> + write32(&bits, 0); // BITMAPINFOHEADER.biClrUsed >> + write32(&bits, 0); // BITMAPINFOHEADER.biClrImportant >> + // BMP files are bottom-to-top so we start from the end... >> + ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; >> + buf += hsize; >> + for(i = 0; i < avctx->height; i++) { >> + n = 3*avctx->width; >> + memcpy(buf, ptr, n); >> + buf += n; >> + memset(buf, 0, n_bytes_per_row-n); >> + buf += n_bytes_per_row-n; >> + ptr -= p->linesize[0]; // ... and go back >> + } -- Michel Bardiaux R&D Director T +32 [0] 2 790 29 41 F +32 [0] 2 790 29 02 E mailto:mbardiaux at mediaxim.be Mediaxim NV/SA Vorstlaan 191 Boulevard du Souverain Brussel 1160 Bruxelles http://www.mediaxim.com/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4