#include "jpegtables.h"
#include "mjpegenc_common.h"
#include "mjpeg.h"
-#include "mjpegenc.h"
typedef struct LJpegEncContext {
AVClass *class;
}
/**
- * Encodes and outputs the entire frame in the JPEG format.
- *
- * @param s The MpegEncContext.
- */
-void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
-{
- int i, nbits, code, table_id;
- MJpegContext *m = s->mjpeg_ctx;
- uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
- m->huff_size_dc_chrominance,
- m->huff_size_ac_luminance,
- m->huff_size_ac_chrominance};
- uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
- m->huff_code_dc_chrominance,
- m->huff_code_ac_luminance,
- m->huff_code_ac_chrominance};
- size_t total_bits = 0;
- size_t bytes_needed;
-
- s->header_bits = get_bits_diff(s);
- // Estimate the total size first
- for (i = 0; i < m->huff_ncode; i++) {
- table_id = m->huff_buffer[i].table_id;
- code = m->huff_buffer[i].code;
- nbits = code & 0xf;
-
- total_bits += huff_size[table_id][code] + nbits;
- }
-
- bytes_needed = (total_bits + 7) / 8;
- ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
-
- for (i = 0; i < m->huff_ncode; i++) {
- table_id = m->huff_buffer[i].table_id;
- code = m->huff_buffer[i].code;
- nbits = code & 0xf;
-
- put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
- if (nbits != 0) {
- put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
- }
- }
-
- m->huff_ncode = 0;
- s->i_tex_bits = get_bits_diff(s);
-}
-
-/**
* Add code and table_id to the JPEG buffer.
*
* @param s The MJpegContext which contains the JPEG buffer.
}
int ff_mjpeg_encode_init(MpegEncContext *s);
-void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_close(MpegEncContext *s);
void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
}
}
+/**
+ * Encodes and outputs the entire frame in the JPEG format.
+ *
+ * @param s The MpegEncContext.
+ */
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
+{
+ int i, nbits, code, table_id;
+ MJpegContext *m = s->mjpeg_ctx;
+ uint8_t *huff_size[4] = {m->huff_size_dc_luminance,
+ m->huff_size_dc_chrominance,
+ m->huff_size_ac_luminance,
+ m->huff_size_ac_chrominance};
+ uint16_t *huff_code[4] = {m->huff_code_dc_luminance,
+ m->huff_code_dc_chrominance,
+ m->huff_code_ac_luminance,
+ m->huff_code_ac_chrominance};
+ size_t total_bits = 0;
+ size_t bytes_needed;
+
+ s->header_bits = get_bits_diff(s);
+ // Estimate the total size first
+ for (i = 0; i < m->huff_ncode; i++) {
+ table_id = m->huff_buffer[i].table_id;
+ code = m->huff_buffer[i].code;
+ nbits = code & 0xf;
+
+ total_bits += huff_size[table_id][code] + nbits;
+ }
+
+ bytes_needed = (total_bits + 7) / 8;
+ ff_mpv_reallocate_putbitbuffer(s, bytes_needed, bytes_needed);
+
+ for (i = 0; i < m->huff_ncode; i++) {
+ table_id = m->huff_buffer[i].table_id;
+ code = m->huff_buffer[i].code;
+ nbits = code & 0xf;
+
+ put_bits(&s->pb, huff_size[table_id][code], huff_code[table_id][code]);
+ if (nbits != 0) {
+ put_sbits(&s->pb, nbits, m->huff_buffer[i].mant);
+ }
+ }
+
+ m->huff_ncode = 0;
+ s->i_tex_bits = get_bits_diff(s);
+}
+
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
{
int size;
ScanTable *intra_scantable, int pred,
uint16_t luma_intra_matrix[64],
uint16_t chroma_intra_matrix[64]);
+void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
int ff_mjpeg_encode_stuffing(MpegEncContext *s);