instead of custom and bloated code to find an index into a w/h array.
Originally committed as revision 21113 to svn://svn.ffmpeg.org/ffmpeg/trunk
19, 2, 1, 34, 35, 36
};
-int h263_get_picture_format(int width, int height)
-{
- if (width == 128 && height == 96)
- return 1;
- else if (width == 176 && height == 144)
- return 2;
- else if (width == 352 && height == 288)
- return 3;
- else if (width == 704 && height == 576)
- return 4;
- else if (width == 1408 && height == 1152)
- return 5;
- else
- return 7;
-}
-
/**
* Returns the 4 bit value that specifies the given aspect ratio.
* This may be one of the standard aspect ratios or it specifies
put_bits(&s->pb, 1, 0); /* camera off */
put_bits(&s->pb, 1, 0); /* freeze picture release off */
- format = h263_get_picture_format(s->width, s->height);
+ format = ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height);
if (!s->h263_plus) {
/* H.263v1 */
put_bits(&s->pb, 3, format);
#include "dsputil.h"
#include "mpegvideo.h"
#include "mpegvideo_common.h"
+#include "h263.h"
#include "mjpegenc.h"
#include "msmpeg4.h"
#include "faandct.h"
break;
case CODEC_ID_H263:
if (!CONFIG_H263_ENCODER) return -1;
- if (h263_get_picture_format(s->width, s->height) == 7) {
+ if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 7) {
av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
return -1;
}
#include "svq1_vlc.h"
/* standard video sizes */
-const struct svq1_frame_size ff_svq1_frame_size_table[8] = {
+const struct svq1_frame_size ff_svq1_frame_size_table[7] = {
{ 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 },
- { 704, 576 }, { 240, 180 }, { 320, 240 }, { -1, -1 }
+ { 704, 576 }, { 240, 180 }, { 320, 240 }
};
#define SVQ1_BLOCK_INTRA 3
struct svq1_frame_size {
- int width;
- int height;
+ uint16_t width;
+ uint16_t height;
};
uint16_t ff_svq1_packet_checksum (const uint8_t *data, const int length,
extern const uint16_t ff_svq1_intra_mean_vlc[256][2];
extern const uint16_t ff_svq1_inter_mean_vlc[512][2];
-extern const struct svq1_frame_size ff_svq1_frame_size_table[8];
+extern const struct svq1_frame_size ff_svq1_frame_size_table[7];
#endif /* AVCODEC_SVQ1_H */
/* output 5 unknown bits (2 + 2 + 1) */
put_bits(&s->pb, 5, 2); /* 2 needed by quicktime decoder */
- for (i = 0; i < 7; i++)
- {
- if ((ff_svq1_frame_size_table[i].width == s->frame_width) &&
- (ff_svq1_frame_size_table[i].height == s->frame_height))
- {
- put_bits(&s->pb, 3, i);
- break;
- }
- }
+ i= ff_match_2uint16(ff_svq1_frame_size_table, FF_ARRAY_ELEMS(ff_svq1_frame_size_table), s->frame_width, s->frame_height);
+ put_bits(&s->pb, 3, i);
if (i == 7)
{
- put_bits(&s->pb, 3, 7);
put_bits(&s->pb, 12, s->frame_width);
put_bits(&s->pb, 12, s->frame_height);
}
return 0;
}
+int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
+ int i;
+ for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++);
+ return i;
+}
+
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
{
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "